summaryrefslogtreecommitdiff
path: root/utils/zonetabconversion.py
blob: adb78fd87363e7d3f86b1aab3394c5e0c2464678 (plain)
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
#!/bin/python2.7

tztable = open("tztable.h", "w")
tztable.write("//This file was generated by the zonetabconversion.py script\n");
tztable.write("static const char* olsonTimezones[] = {\n");

zonefile = open("/usr/share/zoneinfo/zone.tab", "r")
first = True
for line in zonefile:
    # print line
    if line.startswith('#'):
        # print "continue"
        continue
    else:
        tz = line.split(None)[2]
        print tz
        if first:
            first = False
            tztable.write("    \"")
        else:
            tztable.write(",\n    \"")
        tztable.write(tz)
        tztable.write("\"")
        
tztable.write("\n};\n")
tztable.write("\n")
tztable.write("static const int numOlsonTimezones = sizeof olsonTimezones / sizeof *olsonTimezones;\n")
tztable.write("\n")