class timezone – Represents a fixed offset time zone
The timezone class is a subclass of
tzinfo
, each instance of which represents a time zone defined by a fixed offset from UTC.Note that these timezones do not have any offset capability beyond the fixed offset provided during construction. To represent such a timezone, such as a timezone with daylight saving time, a subclass of
tzinfo
must be created.
- class datetime.timezone(offset, name=None)
Construct a timezone object with a fixed
timedelta
offset
from UTC. An optionalname
may be provided, which is a string representing the time zone name.- fromutc(dt)
Convert a UTC time given by
dt
to the local time in this timezone by adding itsoffset
.
- isoformat(dt)
Return a string representing the time zone in ISO 8601 format.