tz_util – Utilities for dealing with timezones in Python

Timezone related utilities for BSON.

class bson.tz_util.FixedOffset(offset, name)

Fixed offset timezone, in minutes east from UTC.

Implementation based from the Python standard library documentation. Defining __getinitargs__ enables pickling / copying.

Parameters:
  • offset (Union[float, timedelta])

  • name (str)

dst(dt)

datetime -> DST offset as timedelta positive east of UTC.

Parameters:

dt (datetime | None)

Return type:

timedelta

tzname(dt)

datetime -> string name of time zone.

Parameters:

dt (datetime | None)

Return type:

str

utcoffset(dt)

datetime -> timedelta showing offset from UTC, negative values indicating West of UTC

Parameters:

dt (datetime | None)

Return type:

timedelta

bson.tz_util.utc: FixedOffset = FixedOffset(datetime.timedelta(0), 'UTC')

Fixed offset timezone representing UTC.