BDE 4.14.0 Production release
|
Provide utilities to map Zoneinfo identifiers to other systems.
This component provides a namespace, baltzo::WindowsTimeZoneUtil
, containing utility functions supporting the use of Windows time-zone facilities with baltzo
facilities. Currently, this component provides functions that map Windows time-zone identifiers to and from baltzo
(Zoneinfo) time-zone identifiers.
The mapping from Windows to Zoneinfo identifiers used by the baltzo
package is defined in the table titled "Mapping for: windows" at http://unicode.org/cldr/charts/32/supplemental/zone_tzid.html
(with any differences noted in the section {Differences from CLDR} below). The Zoneinfo values on the unicode webpage are given in the column labeled "TZID". Each Windows identifier is qualified by one or more "Region" attributes so, in general, there may be more than one Zoneinfo identifier for a given Windows identifier. The mapping in this component uses the default mapping (Region "001"). The 99 entries are:
Current differences from canonical CLDR data:
https://unicode-org.atlassian.net/browse/CLDR-9892
.In this section we show intended use of this component.
This example shows how to find the Zoneinfo time-zone time-zone identifier for a given Windows time-zone identifier, and the inverse operation.
First, given the "Central Standard Time (Mexico)" Windows time-zone identifier, use the getZoneinfoId
method to find the corresponding Zoneinfo time-zone identifier.
Notice that the corresponding Zoneinfo time-zone identifier is "America/Mexico_City".
Next, use getWindowsTimeZoneId
method to find the Windows time-zone identifier corresponding to "America/Mexico_City".
Notice that the time zone returned is "Central Standard Time (Mexico)", the original time-zone identifier.
The following example demonstrates how to create on a Windows platform a baltzo::LocalDatetime
object with the value of the current time.
First, use the Windows GetTimeZoneInformation
function to load a TIME_ZONE_INFORMATION
structure.
The StandardName
member of the structure, of type WCHAR[32]
, contains the Windows time-zone identifier for Standard Time for the system's local time zone.
Next, use the wcstombs_s
function to convert the wide string in the StandardName
member to its multi-byte equivalent in the standardName
buffer, and assign the result to localTimezone
. Note that every Windows time-zone identifier mapped by this component consists entirely of 7-bit ASCII characters.
Now, use the getZoneinfoId
method to find the corresponding Zoneinfo time-zone identifier.
Then, use the Windows GetSystemTime
function to load an SYSTEMTIME
structure with UTC time information. The returned information includes year, month ([1 .. 12]
), day-of-month ([1 .. 31]
), and hour-of-day ([0 .. 23]
). Note bdlt_date and bdlt_time use the same numerical values to represent month, day, etc. The range of years is different but practically the same as they overlap for several centuries around the current time.
Finally, use these Windows SystemTime values and the calculated Zoneinfo time-zone identifier to set the value of a baltzo::LocalDatetime
object.