experimental.clocks.ntp
Interface for using an NTP server as a realtime clock source
This will only work if
we’re using a wifi-supported Pico model
we have a valid network configuration
there’s an accessible NTP server on the network (important if we’re in AP mode)
- class experimental.clocks.ntp.NtpClock
Realtime clock source that uses an external NTP server
Requires a valid network connection on a Pico W or Pico 2 W
- 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 latest time from our NTP source and return it
- Returns
a tuple of the form 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(datetme)
NTP server is read-only, so setting the time is nonsical.
This function won’t do anything, but don’t raise an error.
- 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