pyoda_time.time_zones.cldr package¶
Module contents¶
- class pyoda_time.time_zones.cldr.MapZone¶
Bases:
objectRepresents a single
<mapZone>element in the CLDR Windows zone mapping file.Equality is defined in a component-wise fashion. When comparing two values for equality, the
tzdb_idsproperties must return the same IDs in the same order for the values to be considered equal.- FIXED_OFFSET_TERRITORY: Final[str] = 'ZZ'¶
Identifier used for the “fixed offset” territory.
A zone mapping with this territory will always have a single entry. The value of this constant is “ZZ”.
- PRIMARY_TERRITORY: Final[str] = '001'¶
Identifier used for the primary territory of each Windows time zone.
A zone mapping with this territory will always have a single entry. The value of this constant is “001”.
- __eq__(other: object) bool¶
Compares two
MapZonevalues for equality.See the type documentation for a description of equality semantics.
- Parameters:
other – The value to compare this map zone with.
- Returns:
True if the given value is another map zone equal to this one; false otherwise.
- __init__(windows_id: str, territory: str, tzdb_ids: Sequence[str]) None¶
Creates a new mapping entry.
This constructor is only public for the sake of testability.
- Parameters:
windows_id – Windows system time zone identifier. Must not be null.
territory – Territory code. Must not be null.
tzdb_ids – List of territory codes. Must not be null, and must not contain null values.
- equals(other: MapZone) bool¶
Compares two
MapZonevalues for equality.- Parameters:
other – The value to compare this map zone with.
- Returns:
True if the given value is another map zone equal to this one; false otherwise.
- property territory: str¶
Gets the territory code for this mapping.
This is typically either “001” to indicate that it’s the primary territory for this ID, or “ZZ” to indicate a fixed-offset ID, or a different two-character capitalized code which indicates the geographical territory.
- Returns:
The territory code for this mapping.
- property tzdb_ids: Sequence[str]¶
Gets a read-only non-empty collection of TZDB zone identifiers for this mapping, such as “America/Chicago” and “America/Matamoros” (both of which are TZDB zones associated with the “Central Standard Time” Windows system time zone).
For the primary and fixed-offset territory IDs (“001” and “ZZ”) this always contains exactly one time zone ID. The IDs returned are not necessarily canonical in TZDB.
- Returns:
A read-only non-empty collection of TZDB zone identifiers for this mapping.
- property windows_id: str¶
Gets the Windows system time zone identifier for this mapping, such as “Central Standard Time”.
Most Windows system time zone identifiers use the name for the “standard” part of the zone as the overall identifier. Don’t be fooled: just because a time zone includes “standard” in its identifier doesn’t mean that it doesn’t observe daylight saving time.
- Returns:
The Windows system time zone identifier for this mapping, such as “Central Standard Time”.
- class pyoda_time.time_zones.cldr.WindowsZones¶
Bases:
objectRepresentation of the
<windowsZones>element of CLDR supplemental data.See the CLDR design proposal for more details of the structure of the file from which data is taken. http://cldr.unicode.org/development/development-process/design-proposals/extended-windows-olson-zid-mapping
- __init__() None¶
Raise TypeError if the decorated class has no public constructor.
- Raises:
TypeError – This class is not intended to be instantiated directly.
- __new__() T¶
Raise TypeError if the decorated class has no public constructor.
- Raises:
TypeError – This class is not intended to be instantiated directly.
- property map_zones: Sequence[MapZone]¶
Gets an immutable collection of mappings from Windows system time zones to TZDB time zones.
Each mapping consists of a single Windows time zone ID and a single territory to potentially multiple TZDB IDs that are broadly equivalent to that Windows zone/territory pair.
Mappings for a single Windows system time zone can appear multiple times in this list, in different territories. For example, “Central Standard Time” maps to different TZDB zones in different countries (the US, Canada, Mexico) and even within a single territory there can be multiple zones. Every Windows system time zone covered within this collection has a “primary” entry with a territory code of “001” (which is the value of
MapZone.PRIMARY_TERRITORY) and a single corresponding TZDB zone.This collection is not guaranteed to cover every Windows time zone. Some zones may be unmappable (such as “Mid-Atlantic Standard Time”) and there can be a delay between a new Windows time zone being introduced and it appearing in CLDR, ready to be used by Noda Time. (There’s also bound to be a delay between it appearing in CLDR and being used in your production system.) In practice however, you’re unlikely to wish to use a time zone which isn’t covered here.
- Returns:
An immutable collection of mappings from Windows system time zones to TZDB time zones.
- property primary_mapping: MappingProxyType¶
Gets an immutable dictionary of primary mappings, from Windows system time zone ID to TZDB zone ID. This corresponds to the “001” territory which is present for every zone within the mapping file.
Each value in the dictionary is a canonical ID in CLDR, but it may not be canonical in TZDB. For example, the ID corresponding to “India Standard Time” is “Asia/Calcutta”, which is canonical in CLDR but is an alias in TZDB for “Asia/Kolkata”. To obtain a canonical TZDB ID, use
TzdbDateTimeZoneSource.canonical_id_map.- Returns:
An immutable dictionary of primary mappings, from Windows system time zone ID to TZDB zone ID.
- property tzdb_version: str¶
Gets the TZDB version this Windows zone mapping data was created from.
The CLDR mapping file usually lags behind the TZDB file somewhat - partly because the mappings themselves don’t always change when the time zone data does. For example, it’s entirely reasonable for a
TzdbDateTimeZoneSourcewith atzdb_versionof “2013b” to be supply aWindowsZonesobject with atzdb_versionof “2012f”.- Returns:
The TZDB version this Windows zone mapping data was created from.
- property version: str¶
Gets the version of the Windows zones mapping data read from the original file.
As with other IDs, this should largely be treated as an opaque string, but the current method for generating this from the mapping file extracts a number from an element such as <c><version number=”$Revision: 7825 $”/></c>. This is a Subversion revision number, but that association should only be used for diagnostic curiosity, and never assumed in code.
- Returns:
The version of the Windows zones mapping data read from the original file.
- property windows_version: str¶
Gets the Windows time zone database version this Windows zone mapping data was created from.
At the time of this writing, this is populated (by CLDR) from the registry key HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionTime ZonesTzVersion, so “7dc0101” for example.
- Returns:
The Windows time zone database version this Windows zone mapping data was created from.