adafruit_datetime
¶
Concrete date/time and related types.
See http://www.iana.org/time-zones/repository/tz-link.html for time zone and DST data sources.
Implementation Notes¶
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- class adafruit_datetime.date(year: int, month: int, day: int)¶
A date object represents a date (year, month and day) in an idealized calendar, the current Gregorian calendar indefinitely extended in both directions. Objects of this type are always naive.
Creates a new date object.
- Parameters:
- classmethod fromisoformat(date_string: str) date ¶
Return a date object constructed from an ISO date format. Valid format is
YYYY-MM-DD
- classmethod fromordinal(ordinal: int) date ¶
Return the date corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1.
- classmethod fromtimestamp(t: float) date ¶
Return the local date corresponding to the POSIX timestamp, such as is returned by time.time().
- replace(year: int | None = None, month: int | None = None, day: int | None = None)¶
Return a date with the same value, except for those parameters given new values by whichever keyword arguments are specified. If no keyword arguments are specified - values are obtained from datetime object.
- timetuple() struct_time ¶
Return a time.struct_time such as returned by time.localtime(). The hours, minutes and seconds are 0, and the DST flag is -1.
- class adafruit_datetime.datetime(year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0, tzinfo: tzinfo | None = None, *, fold: int = 0)¶
A datetime object is a single object containing all the information from a date object and a time object. Like a date object, datetime assumes the current Gregorian calendar extended in both directions; like a time object, datetime assumes there are exactly 3600*24 seconds in every day.
Creates a new date object.
- Parameters:
- classmethod combine(date: date, time: time, tzinfo: bool = True) datetime ¶
Return a new datetime object whose date components are equal to the given date object’s, and whose time components are equal to the given time object’s.
- dst() timedelta | None ¶
If tzinfo is None, returns None, else returns self.tzinfo.dst(self), and raises an exception if the latter doesn’t return None or a timedelta object with magnitude less than one day.
- classmethod fromisoformat(date_string: str) datetime ¶
Return a datetime object constructed from an ISO date format. Valid format is
YYYY-MM-DD[*HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]]
- classmethod fromtimestamp(timestamp: float, tz: tzinfo | None = None) datetime ¶
Return the local date corresponding to the POSIX timestamp, such as is returned by time.time().
- isoformat(sep: str = 'T', timespec: str = 'auto') str ¶
Return a string representing the date and time in ISO8601 format.
- replace(year: int | None = None, month: str | None = None, day: str | None = None, hour: str | None = None, minute: str | None = None, second: str | None = None, microsecond: str | None = None, tzinfo: bool = True, *, fold: int | None = None) datetime ¶
Return a datetime with the same attributes, except for those attributes given new values by whichever keyword arguments are specified.
- time() time ¶
Return time object with same hour, minute, second, microsecond and fold. tzinfo is None. See also method timetz().
- timetuple() struct_time ¶
Return local time tuple compatible with time.localtime().
- property tzinfo: tzinfo | None¶
The object passed as the tzinfo argument to the datetime constructor, or None if none was passed.
- classmethod utcfromtimestamp(timestamp: float) datetime ¶
Return the UTC datetime corresponding to the POSIX timestamp, with tzinfo None
- class adafruit_datetime.time(hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0, tzinfo: tzinfo | None = None, *, fold: int = 0)¶
A time object represents a (local) time of day, independent of any particular day, and subject to adjustment via a tzinfo object.
- classmethod fromisoformat(time_string: str) time ¶
Return a time object constructed from an ISO date format. Valid format is
HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]
- isoformat(timespec: str = 'auto') str ¶
Return a string representing the time in ISO 8601 format, one of: HH:MM:SS.ffffff, if microsecond is not 0
HH:MM:SS, if microsecond is 0
HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]], if utcoffset() does not return None
HH:MM:SS+HH:MM[:SS[.ffffff]], if microsecond is 0 and utcoffset() does not return None
- property tzinfo: tzinfo | None¶
The object passed as the tzinfo argument to the time constructor, or None if none was passed.
- class adafruit_datetime.timedelta(days: int = 0, seconds: int = 0, microseconds: int = 0, milliseconds: int = 0, minutes: int = 0, hours: int = 0, weeks: int = 0)¶
A timedelta object represents a duration, the difference between two dates or times.
- class adafruit_datetime.timezone(offset: ~adafruit_datetime.timedelta, name: str | object = <object object>)¶
The timezone class is a subclass of tzinfo, each instance of which represents a timezone defined by a fixed offset from UTC.
Objects of this class cannot be used to represent timezone information in the locations where different offsets are used in different days of the year or where historical changes have been made to civil time.
- class adafruit_datetime.tzinfo¶
This is an abstract base class, meaning that this class should not be instantiated directly. Define a subclass of tzinfo to capture information about a particular time zone.
- dst(dt: datetime) None ¶
Return the DST setting correspinding to the datetime object dt, as a number.
DST usage is currently not implemented for this library.