tz.win
This module provides an interface to the native time zone data on Windows,
including datetime.tzinfo
implementations.
Attempting to import this module on a non-Windows platform will raise an
ImportError
.
Classes
- class dateutil.tz.win.tzres(tzres_loc='tzres.dll')[source]
Class for accessing
tzres.dll
, which contains timezone name related resources.Added in version 2.5.0.
- load_name(offset)[source]
Load a timezone name from a DLL offset (integer).
>>> from dateutil.tzwin import tzres >>> tzr = tzres() >>> print(tzr.load_name(112)) 'Eastern Standard Time'
- Parameters:
offset – A positive integer value referring to a string from the tzres dll.
Note
Offsets found in the registry are generally of the form
@tzres.dll,-114
. The offset in this case is 114, not -114.
- name_from_string(tzname_str)[source]
Parse strings as returned from the Windows registry into the time zone name as defined in the registry.
>>> from dateutil.tzwin import tzres >>> tzr = tzres() >>> print(tzr.name_from_string('@tzres.dll,-251')) 'Dateline Daylight Time' >>> print(tzr.name_from_string('Eastern Standard Time')) 'Eastern Standard Time'
- Parameters:
tzname_str – A timezone name string as returned from a Windows registry key.
- Returns:
Returns the localized timezone string from tzres.dll if the string is of the form @tzres.dll,-offset, else returns the input string.
- class dateutil.tz.win.tzwin(name)[source]
Time zone object created from the zone info in the Windows registry
These are similar to
dateutil.tz.tzrange
objects in that the time zone data is provided in the format of a single offset rule for either 0 or 2 time zone transitions per year.- Param:
name The name of a Windows time zone key, e.g. “Eastern Standard Time”. The full list of keys can be retrieved with
tzwin.list()
.
- display()
Return the display name of the time zone.
- static list()
Return a list of all time zones known to the system.
- transitions(year)
For a given year, get the DST on and off transition times, expressed always on the standard time side. For zones with no transitions, this function returns
None
.- Parameters:
year – The year whose transitions you would like to query.
- Returns:
Returns a
tuple
ofdatetime.datetime
objects,(dston, dstoff)
for zones with an annual DST transition, orNone
for fixed offset zones.
- class dateutil.tz.win.tzwinlocal[source]
Class representing the local time zone information in the Windows registry
While
dateutil.tz.tzlocal
makes system calls (via thetime
module) to retrieve time zone information,tzwinlocal
retrieves the rules directly from the Windows registry and creates an object likedateutil.tz.tzwin
.Because Windows does not have an equivalent of
time.tzset()
, on Windows,dateutil.tz.tzlocal
instances will always reflect the time zone settings at the time that the process was started, meaning changes to the machine’s time zone settings during the run of a program on Windows will not be reflected bydateutil.tz.tzlocal
. Becausetzwinlocal
reads the registry directly, it is unaffected by this issue.- display()
Return the display name of the time zone.
- transitions(year)
For a given year, get the DST on and off transition times, expressed always on the standard time side. For zones with no transitions, this function returns
None
.- Parameters:
year – The year whose transitions you would like to query.
- Returns:
Returns a
tuple
ofdatetime.datetime
objects,(dston, dstoff)
for zones with an annual DST transition, orNone
for fixed offset zones.