File: WindowsZones.csx

package info (click to toggle)
freerdp2 2.0.0~git20190204.1.2693389a+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 22,772 kB
  • sloc: ansic: 307,908; xml: 1,676; sh: 770; perl: 231; makefile: 158; python: 65
file content (91 lines) | stat: -rw-r--r-- 2,556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * FreeRDP: A Remote Desktop Protocol Implementation
 * TZID to Windows TimeZone Identifier Table Generator
 *
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *	 http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* Run with ' csi scripts/WindowsZones.csx' from freerdp checkout root */

#r "System.Xml"

using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/* 
 * this script uses windowsZones.xml which can be obtained at:
 * http://www.unicode.org/repos/cldr/tags/latest/common/supplemental/windowsZones.xml
 */

string tzid, windows;
const string file = @"winpr/libwinpr/timezone/WindowsZones.c";
const string zonesUrl = @"http://www.unicode.org/repos/cldr/tags/latest/common/supplemental/windowsZones.xml";
List<string> list = new List<string>();
StreamWriter stream = new StreamWriter(file, false);
XmlTextReader reader = new XmlTextReader(zonesUrl);

Console.WriteLine("Updating " + file);
stream.WriteLine("/* ");
stream.WriteLine(" * Automatically generated with scripts/WindowsZones.csx");
stream.WriteLine(" */ ");
stream.WriteLine();

stream.WriteLine("struct _WINDOWS_TZID_ENTRY");
stream.WriteLine("{");
stream.WriteLine("\tconst char* windows;");
stream.WriteLine("\tconst char* tzid;");
stream.WriteLine("};");
stream.WriteLine("typedef struct _WINDOWS_TZID_ENTRY WINDOWS_TZID_ENTRY;");
stream.WriteLine();

while (reader.Read())
{
	switch (reader.NodeType)
	{
		case XmlNodeType.Element:

			if (reader.Name.Equals("mapZone"))
			{
				tzid = reader.GetAttribute("type");
				windows = reader.GetAttribute("other");
			
				string entry = String.Format("\"{0}\", \"{1}\"", windows, tzid);
				
				if (!list.Contains(entry))
					list.Add(entry);
			}
		
			break;
	}
}

list.Sort();

stream.WriteLine("const WINDOWS_TZID_ENTRY WindowsTimeZoneIdTable[] =");
stream.WriteLine("{");

foreach (string entry in list)
{
		stream.Write("\t{ ");
		stream.Write(entry);
		stream.WriteLine(" },");	
}

stream.WriteLine("};");

stream.Close();