Skip to content
This repository

Timezone sorting #8

Merged
merged 1 commit into from over 2 years ago

3 participants

apenwarr Ed Hunsinger Brian Rosner
apenwarr

Hi,

I added a simple patch to change the way timezones are sorted by default, in a way that I think is more user friendly. With this change, we sort by (GMT offset, name) rather than just by (name). Since the names tend to be hard to guess - my personal timezone is "America/Vancouver" even though I'm in Canada? - this makes it easier to find things in the list.

Have fun,

Avery

Ed Hunsinger

+1

Brian Rosner brosner merged commit 8da6548 into from November 11, 2011
Brian Rosner brosner closed this November 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 28, 2010
apenwarr Sort timezones in order of GMT offset, not just name. 3ce983c
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  timezones/zones.py
6  timezones/zones.py
@@ -10,4 +10,8 @@
10 10
 
11 11
 for tz in pytz.common_timezones:
12 12
     now = datetime.now(pytz.timezone(tz))
13  
-    PRETTY_TIMEZONE_CHOICES.append((tz, "(GMT%s) %s" % (now.strftime("%z"), tz)))
  13
+    ofs = now.strftime("%z")
  14
+    PRETTY_TIMEZONE_CHOICES.append((int(ofs), tz, "(GMT%s) %s" % (ofs, tz)))
  15
+PRETTY_TIMEZONE_CHOICES.sort()
  16
+for i in xrange(len(PRETTY_TIMEZONE_CHOICES)):
  17
+    PRETTY_TIMEZONE_CHOICES[i] = PRETTY_TIMEZONE_CHOICES[i][1:]
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.