The OpenD Programming Language

TZConversions

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

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.

Members

Variables

fromWindows
string[][string] fromWindows;

The key is the IANA time zone database name, and the value is a list of Windows time zone names which are close (usually only one, but it could be multiple).

toWindows
string[][string] toWindows;

The key is the Windows time zone name, and the value is a list of IANA TZ database names which are close (currently only ever one, but it allows for multiple in case it's ever necessary).

Throws

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

// Parse the conversions from a local file.
auto text = std.file.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(std.net.curl.get(url));

Meta