File: zonetabconversion.py

package info (click to toggle)
libkolabxml 1.2.1-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,612 kB
  • sloc: cpp: 9,911; ansic: 596; xml: 430; python: 221; php: 194; sh: 94; makefile: 12; cs: 9
file content (44 lines) | stat: -rwxr-xr-x 1,084 bytes parent folder | download | duplicates (3)
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
#!/bin/python2.7

import os

timezones = []
directory = '/usr/share/zoneinfo/'

for root, directories, filenames in os.walk(directory):
    for filename in filenames:
        if filename.endswith('.tab'):
            continue

        if filename.endswith('.zi'):
            continue

        if filename == 'leapseconds':
            continue

        if filename == 'posixrules':
            continue

        zone = os.path.join(root[len(directory):], filename)

        if zone.startswith("posix/"):
            continue

        if zone.startswith("right/"):
            continue

        timezones.append(zone)


timezones = sorted(list(set(timezones)))

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

tztable.write('    "')
tztable.write('",\n    "'.join(timezones))
tztable.write('"\n};\n')
tztable.write('\n')
tztable.write('static const long unsigned int numOlsonTimezones = sizeof olsonTimezones / sizeof *olsonTimezones;\n')
tztable.write("\n")