Created
May 4, 2016 02:08
-
-
Save righ/61c83d856323b73ee07a26ec2f40f210 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import sys | |
def format_timezones(timezones, descriptor=sys.stdout): | |
_tz = () | |
for tz in sorted(t.split('/') for t in timezones): | |
for indent, region in enumerate(tz): | |
if len(_tz) > indent and _tz[indent] == tz[indent]: | |
continue | |
if len(tz) - 1 == indent: | |
descriptor.write('{}- {}\n'.format(' ' * indent, '/'.join(tz))) | |
else: | |
descriptor.write('{}+ {}\n'.format(' ' * indent, region)) | |
_tz = tz | |
if __name__ == '__main__': | |
import pytz | |
format_timezones(pytz.all_timezones) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment