Skip to content

Commit

Permalink
Fixed #228 -- Better handling of timezones. Thanks, rmunn
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@347 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jul 29, 2005
1 parent 017b875 commit 47ce615
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions django/core/db/typecasts.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ def typecast_timestamp(s): # does NOT store time zone information
# "2005-07-29 09:56:00-05" # "2005-07-29 09:56:00-05"
if not s: return None if not s: return None
d, t = s.split() d, t = s.split()
if t[-3] in ('-', '+'): # Extract timezone information, if it exists. Currently we just throw
t = t[:-3] # Remove the time-zone information, if it exists. # it away, but in the future we may make use of it.
if '-' in t:
t, tz = t.split('-', 1)
tz = '-' + tz
elif '+' in t:
t, tz = t.split('+', 1)
tz = '+' + tz
else:
tz = ''
dates = d.split('-') dates = d.split('-')
times = t.split(':') times = t.split(':')
seconds = times[2] seconds = times[2]
Expand Down

0 comments on commit 47ce615

Please sign in to comment.