I apologize for being a dick. It won't happen again.

I was actually thinking that the 25 standard
timezones (which make a reasonable list or
can be easily generated by clicking a map)
could serve as a filter to make the detail
list reasonably sized.

Something like this:

import pytz
import datetime
import sqlite3
import random

utc = pytz.timezone('UTC')
utc_dt = datetime.datetime(2007,1,1,0,0,0,tzinfo=utc)
offset_zone = []

for i in pytz.all_timezones:
  the_zone = pytz.timezone(i)
  loc_dt = utc_dt.astimezone(the_zone)
  loc_offset = loc_dt.strftime('%z')
  offset_zone.append((loc_offset,the_zone.zone))

con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.executescript("""
    create table tz(
        offset,
        zone
    );
    """)

cur.executemany("""
INSERT INTO tz(offset,
               zone)
VALUES      (?,?)"""
, offset_zone)

cur.execute("""
SELECT DISTINCT offset
FROM  tz
WHERE offset LIKE '+%'
ORDER BY offset;
""")

east = cur.fetchall()

cur.execute("""
SELECT DISTINCT offset
FROM  tz
WHERE offset LIKE '-%'
ORDER BY offset DESC;
""")

west = cur.fetchall()

distinct_offsets = east + west

print
print 'Choose your GMT offset:'
for i in distinct_offsets:
  if i[0]=='+0000' or i[0]=='+0600' or i[0]=='+1200' or i[0]=='-1200'
or i[0]=='-0600':
    print
  print i[0],

print
print

the_choice = random.choice(distinct_offsets)

print 'Offset',the_choice[0],'chosen.'
print

cur.execute("""
SELECT offset,
       zone
FROM   tz
WHERE offset=?
ORDER BY offset;
""",the_choice)

list_o_zones = cur.fetchall()

print 'Which timezone?'
print

for i in list_o_zones: print i[0],i[1]


##  Choose your GMT offset:
##
##  +0000 +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545
##  +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130
##  +1200 +1300 +1345 +1400
##  -1200 -1100 -1000 -0930 -0900 -0800 -0700
##  -0600 -0500 -0400 -0330 -0300 -0200 -0100
##
##  Offset -0930 chosen.
##
##  Which timezone?
##
##  -0930 Pacific/Marquesas
##
##
##
##  Choose your GMT offset:
##
##  +0000 +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545
##  +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130
##  +1200 +1300 +1345 +1400
##  -1200 -1100 -1000 -0930 -0900 -0800 -0700
##  -0600 -0500 -0400 -0330 -0300 -0200 -0100
##
##  Offset +0945 chosen.
##
##  Which timezone?
##
##  +0945 Australia/Eucla
##
##
##
##  Choose your GMT offset:
##
##  +0000 +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545
##  +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130
##  +1200 +1300 +1345 +1400
##  -1200 -1100 -1000 -0930 -0900 -0800 -0700
##  -0600 -0500 -0400 -0330 -0300 -0200 -0100
##
##  Offset -0100 chosen.
##
##  Which timezone?
##
##  -0100 America/Scoresbysund
##  -0100 Atlantic/Azores
##  -0100 Atlantic/Cape_Verde
##  -0100 Etc/GMT+1
##
##
##
##  Choose your GMT offset:
##
##  +0000 +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545
##  +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130
##  +1200 +1300 +1345 +1400
##  -1200 -1100 -1000 -0930 -0900 -0800 -0700
##  -0600 -0500 -0400 -0330 -0300 -0200 -0100
##
##  Offset +1000 chosen.
##
##  Which timezone?
##
##  +1000 Antarctica/DumontDUrville
##  +1000 Asia/Sakhalin
##  +1000 Asia/Vladivostok
##  +1000 Australia/Brisbane
##  +1000 Australia/Lindeman
##  +1000 Australia/Queensland
##  +1000 Etc/GMT-10
##  +1000 Pacific/Guam
##  +1000 Pacific/Port_Moresby
##  +1000 Pacific/Saipan
##  +1000 Pacific/Truk
##  +1000 Pacific/Yap
##
##
##
##  Choose your GMT offset:
##
##  +0000 +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545
##  +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130
##  +1200 +1300 +1345 +1400
##  -1200 -1100 -1000 -0930 -0900 -0800 -0700
##  -0600 -0500 -0400 -0330 -0300 -0200 -0100
##
##  Offset +0300 chosen.
##
##  Which timezone?
##
##  +0300 Africa/Addis_Ababa
##  +0300 Africa/Asmara
##  +0300 Africa/Asmera
##  +0300 Africa/Dar_es_Salaam
##  +0300 Africa/Djibouti
##  +0300 Africa/Kampala
##  +0300 Africa/Khartoum
##  +0300 Africa/Mogadishu
##  +0300 Africa/Nairobi
##  +0300 Antarctica/Syowa
##  +0300 Asia/Aden
##  +0300 Asia/Baghdad
##  +0300 Asia/Bahrain
##  +0300 Asia/Kuwait
##  +0300 Asia/Qatar
##  +0300 Asia/Riyadh
##  +0300 Etc/GMT-3
##  +0300 Europe/Moscow
##  +0300 Europe/Volgograd
##  +0300 Indian/Antananarivo
##  +0300 Indian/Comoro
##  +0300 Indian/Mayotte
##  +0300 W-SU



##  Choose your GMT offset:
##
##  +0000 +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545
##  +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130
##  +1200 +1300 +1345 +1400
##  -1200 -1100 -1000 -0930 -0900 -0800 -0700
##  -0600 -0500 -0400 -0330 -0300 -0200 -0100
##
##  Offset -0600 chosen.
##
##  Which timezone?
##
##  -0600 America/Belize
##  -0600 America/Cancun
##  -0600 America/Chicago
##  -0600 America/Costa_Rica
##  -0600 America/El_Salvador
##  -0600 America/Guatemala
##  -0600 America/Indiana/Knox
##  -0600 America/Indiana/Petersburg
##  -0600 America/Indiana/Tell_City
##  -0600 America/Indiana/Vincennes
##  -0600 America/Indiana/Winamac
##  -0600 America/Knox_IN
##  -0600 America/Managua
##  -0600 America/Menominee
##  -0600 America/Merida
##  -0600 America/Mexico_City
##  -0600 America/Monterrey
##  -0600 America/North_Dakota/Center
##  -0600 America/North_Dakota/New_Salem
##  -0600 America/Rainy_River
##  -0600 America/Rankin_Inlet
##  -0600 America/Regina
##  -0600 America/Swift_Current
##  -0600 America/Tegucigalpa
##  -0600 America/Winnipeg
##  -0600 CST6CDT
##  -0600 Canada/Central
##  -0600 Canada/East-Saskatchewan
##  -0600 Canada/Saskatchewan
##  -0600 Etc/GMT+6
##  -0600 Mexico/General
##  -0600 Pacific/Galapagos
##  -0600 US/Central
##  -0600 US/Indiana-Starke

Why do all the Etc/GMTxxx zones appear to have
the sign of their offset reversed? Such as
-0600 for Etc/GMT+6?

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to