View source code
Display the source code in std/datetime/timezone.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.datetime.timezone.parseTZConversions

Provides the conversions between the IANA time zone database time zone names (which POSIX systems use) and the time zone names that Windows uses.

TZConversions parseTZConversions (
  string windowsZonesXMLText
) pure @safe;

Windows uses a different set of time zone names than the IANA time zone database does, and how they correspond to one another changes over time (particularly when Microsoft updates Windows). windowsZones.xml provides the current conversions (which may or may not match up with what's on a particular Windows box depending on how up-to-date it is), and parseTZConversions reads in those conversions from windowsZones.xml so that a D program can use those conversions.

However, it should be noted that the time zone information on Windows is frequently less accurate than that in the IANA time zone database, and if someone really wants accurate time zone information, they should use the IANA time zone database files with PosixTimeZone on Windows rather than WindowsTimeZone, whereas WindowsTimeZone makes more sense when trying to match what Windows will think the time is in a specific time zone.

Also, the IANA time zone database has a lot more time zones than Windows does.

Parameters

NameDescription
windowsZonesXMLText The text from windowsZones.xml

Throws

Exception if there is an error while parsing the given XML.

// Parse the conversions from a local file.
auto text = readText("path/to/windowsZones.xml");
auto conversions = parseTZConversions(text);

// Alternatively, grab the XML file from the web at runtime
// and parse it so that it's guaranteed to be up-to-date, though
// that has the downside that the code needs to worry about the
// site being down or unicode.org changing the URL.
auto url = "http://unicode.org/cldr/data/common/supplemental/windowsZones.xml";
auto conversions2 = parseTZConversions(get(url));

Authors

Jonathan M Davis

License

Boost License 1.0.