Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A little snippet I came up with to get a list of olson to windows time zone mappings from the xml at <a href="http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml" rel="nofollow noreferrer">http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml</a></p> <pre><code>private static void LoadMappingsO() { var file = new FileInfo("windowsZones.xml"); if (!file.Exists) { return; } var map = new Dictionary&lt;string, string&gt;(); using (var reader = file.OpenText()) { var readerSettings = new XmlReaderSettings { XmlResolver = null, ProhibitDtd = false }; using (var xmlReader = XmlReader.Create(reader, readerSettings)) { var document = new XPathDocument(xmlReader); var navigator = document.CreateNavigator(); var nodes = navigator.Select("/supplementalData/windowsZones/mapTimezones/mapZone"); while (nodes.MoveNext()) { var node = nodes.Current; if (node == null) continue; var olsonNames = node.GetAttribute("type", "").Split(' '); var windowsName = node.GetAttribute("other", ""); foreach (var olsonName in olsonNames) { if (!map.ContainsKey(olsonName)) { map.Add(olsonName, windowsName); } } } } } using (TextWriter tw = new StreamWriter("dict.txt", false)) { foreach (var key in map.Keys) { tw.WriteLine(string.Format("{{\"{0}\", \"{1}\"}},", key, map[key])); } } } </code></pre> <p><strong>UPDATE (Using Linq Xml):</strong></p> <pre><code>private static void LoadMappings() { var map = new Dictionary&lt;string, string&gt;(); var xdoc = XDocument.Load("windowsZones.xml"); var zones = xdoc.XPathSelectElements("/supplementalData/windowsZones/mapTimezones/mapZone"); foreach (var zone in zones) { var olsonNames = zone.Attribute("type")?.Value.Split(' '); if (olsonNames == null) continue; var windowsName = zone.Attribute("other")?.Value; if (string.IsNullOrWhiteSpace(windowsName)) continue; foreach (var olsonName in olsonNames) { map[olsonName] = windowsName; } } using (TextWriter tw = new StreamWriter("dict.txt", false)) { foreach (var key in map.Keys) { tw.WriteLine($"{{\"{key}\", \"{map[key]}\"}},"); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload