Skip to content

Instantly share code, notes, and snippets.

@gfranxman
Created July 10, 2015 16:17
Show Gist options
  • Select an option

  • Save gfranxman/9af990acb122b9a64cd5 to your computer and use it in GitHub Desktop.

Select an option

Save gfranxman/9af990acb122b9a64cd5 to your computer and use it in GitHub Desktop.
Django US TIMEZONE Choices.
import pytz
TIMEZONES = [ (t,t) for t in pytz.common_timezones if t.startswith("US/") ]
TIMEZONES.sort( key=lambda t: pytz.timezone(t[0])._utcoffset.seconds/3600, reverse=True )
>>> TIMEZONES
[('US/Eastern', 'US/Eastern'), ('US/Central', 'US/Central'), ('US/Mountain', 'US/Mountain'), ('US/Arizona', 'US/Arizona'), ('US/Pacific', 'US/Pacific'), ('US/Alaska', 'US/Alaska'), ('US/Hawaii', 'US/Hawaii')]
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment