experimental.clocks.null_clock
- class experimental.clocks.null_clock.NullClock
A placeholder replacement for a realtime clock.
This class sets the base time to 1 January, 1970, 00:00:00.0 and adds the current value of ticks_ms() to that time. This allows the RTC to tick up, but won’t actually be indicitave of the real time.
Because ticks_ms() rolls over ever 2**30 ms, the datetime returned by this clock will also roll over at the same interval. BUT, 2**30 ms ~= 298 hours, so unless your EuroPi is powered-on 12 days continuously this won’t ever cause problems.
- check_valid_datetime(datetime)
Check if a datetime contains valid values.
- Raises
ValueError – if any field is out of range
- Parameters
datetime – The datetime tuple to validate
- datetime()
Get the current UTC time as a tuple.
see: https://docs.micropython.org/en/latest/library/time.html#time.localtime
- Returns
a tuple of the form (0-year, 1-month, 2-day, 3-hour, 4-minutes, 5-seconds, 6-weekday, 7-yearday)
- is_leap_year(datetime)
Determine if the datetime’s year is a leap year or not.
- Returns
True if the datetime is a leap year, otherwise False
- month_length(datetime)
Get the numer of days in the month.
This takes leap-years into consideration
- Returns
The number of days in the datetime’s month
- set_datetime(datetime)
Set the clock’s current UTC time.
If the clock does not support setting (e.g. it’s an NTP source we can only read from) your sub-class should implement this method anyway and simply pass.
see: https://docs.micropython.org/en/latest/library/time.html#time.localtime
- Parameters
datetime – A tuple of the form (0-year, 1-month, 2-day, 3-hour, 4-minutes, 5-seconds, 6-weekday, 7-yearday)
- year_length(datetime)
Determine the number of days in the datetime’s year.
- Returns
The number of days in the year, taking leap years into account