constants.py 559 B

1234567891011121314151617
  1. from datetime import datetime
  2. import pytz
  3. ALL_TIMEZONE_CHOICES = tuple(zip(pytz.all_timezones, pytz.all_timezones))
  4. COMMON_TIMEZONE_CHOICES = tuple(
  5. zip(pytz.common_timezones, pytz.common_timezones)
  6. )
  7. PRETTY_TIMEZONE_CHOICES = []
  8. for tz in pytz.common_timezones:
  9. now = datetime.now(pytz.timezone(tz))
  10. ofs = now.strftime("%z")
  11. PRETTY_TIMEZONE_CHOICES.append((int(ofs), tz, "(GMT%s) %s" % (ofs, tz)))
  12. PRETTY_TIMEZONE_CHOICES.sort()
  13. for i in range(len(PRETTY_TIMEZONE_CHOICES)):
  14. PRETTY_TIMEZONE_CHOICES[i] = PRETTY_TIMEZONE_CHOICES[i][1:]