view tools/tz.py @ 693:ad69236e8501

For issue #52, update many 3rd party Javascript libraries. Updated to jquery 1.10.2, jquery ui 1.10.3. This broke a lot of stuff. - Found a newer version of the jquery cycle all plugin (3.0.3). - Updated JPlayer to 2.4.0. - Updated to MarkItUp 1.1.14. This also required me to add multiline attributes set to true on various buttons in the markdown set. - As per a stackoverflow post, added some code to get multiline titles in a jQuery UI dialog. They removed that functionality but allow you to put it back. Tweaked the MarkItUp preview CSS to show blockquotes in italic. Did not update TinyMCE at this time. I'm not using the JQuery version and this version appears to work ok for now. What I should do is make a repo for MarkItUp and do a vendor branch thing so I don't have to futz around diffing directories to figure out if I'll lose changes when I update.
author Brian Neal <bgneal@gmail.com>
date Wed, 04 Sep 2013 19:55:20 -0500
parents ed6202fb08b6
children
line wrap: on
line source
"""
This program generates the data used by the timezone.js Javascript.
This data is used to create the 2 dropdown select boxes for timezones.
"""
import pytz
from pprint import pprint

def format_locations(locs):
    ss = ["[%s]" % ", ".join(["'%s'" % l for l in loc]) for loc in locs]
    return "%s" % ",\n".join(ss)

# get a list of areas

zones = [z.split('/') for z in pytz.common_timezones]
areas = set([zone[0] for zone in zones if len(zone) > 1])
areas = list(areas)
areas.sort()

locations = dict([(area, []) for area in areas])

#pprint(locations)

for zone in pytz.common_timezones:
    if zone.count('/') == 0:
        continue
    area, loc = zone.split('/', 1)
    if area in locations:
        locations[area].append(loc.replace('_', ' '))

#pprint(locations)

for area in locations.iterkeys():
    locations[area].sort()

locs = []
for area in areas:
    locs.append(locations[area])

#pprint(locs)

default_area = areas.index('US')
default_location = locs[default_area].index('Pacific')

print """\
var gcalTzInfo = {
    areas: [%s],
    locations: [%s],
    default_area: %s,
    default_location: %s
};
""" % (", ".join(["'%s'" % area for area in areas]), 
        format_locations(locs),
        default_area,
        default_location,
        )