tzdb
¶
IANA timezones for adafruit_datetime
Author(s): Evin Dunn
Implementation Notes¶
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Datetime library: https://github.com/adafruit/Adafruit_CircuitPython_DateTime
- class tzdb.timezone(tz_name: str)¶
Subclass of tzinfo for calculating the utc offset of a given datetime
A python file is generated in _zones/ for each timezone in the following format:
tz_data = { "2022-01-01T00:00:00": -6.0, "2022-03-13T03:00:00": -5.0, "2022-11-06T02:00:00": -6.0, "2022-10-31T00:00:00": -5.0 }
Meaning that:
On January 1st, the UTC offset is -6
On March 13th, the UTC offset changes to -5
etc.
One of these files is lazily imported based on the tz_name passed to the constructor
Create a new timezone with tz_name. The timezone contains the offset data for tz_name in the _TZ_DB.
- Param
tz_name The name of the IANA timezone to create
- fromutc(dt: adafruit_datetime.datetime) adafruit_datetime.datetime ¶
datetime in UTC -> datetime in local time
- Parameters
dt (adafruit_datetime.datetime) – The UTC datetime to convert to local time
- Returns
The UTC datetime dt in local time
- Return type
adafruit_datetime.datetime
- property name¶
return: The name of the timezone passed to the constructor :rtype: str
- tzname(dt: adafruit_datetime.datetime) str ¶
- Parameters
dt (adafruit_datetime.datetime) – The datetime to retrieve the timezone name for
- Returns
the time zone name corresponding to the datetime object dt, as a string
- Return type
- utcoffset(dt: adafruit_datetime.datetime) adafruit_datetime.timedelta ¶
- Parameters
dt (adafruit_datetime.datetime) – The datetime to calculate the offset for
- Returns
The offset from UTC in the given timezone at the given dt, as a timedelta object that is positive east of UTC.
- Return type
adafruit_datetime.timedelta