#!/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")
        
