diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-07-29 21:40:09 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-07-29 21:40:09 +0000 |
| commit | 47ce61533a5364c6d45803a696d86cbcb1ed2b33 (patch) | |
| tree | 86dfb97cf53e99b5e6b63be9eb7b1581887a797c | |
| parent | 017b8753a63d141e1ba5cbed5e7a609a7e1a4bab (diff) | |
Fixed #228 -- Better handling of timezones. Thanks, rmunn
git-svn-id: http://code.djangoproject.com/svn/django/trunk@347 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/db/typecasts.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/django/core/db/typecasts.py b/django/core/db/typecasts.py index 19d11d8444..9f73ec87a2 100644 --- a/django/core/db/typecasts.py +++ b/django/core/db/typecasts.py @@ -21,8 +21,16 @@ def typecast_timestamp(s): # does NOT store time zone information # "2005-07-29 09:56:00-05" if not s: return None d, t = s.split() - if t[-3] in ('-', '+'): - t = t[:-3] # Remove the time-zone information, if it exists. + # Extract timezone information, if it exists. Currently we just throw + # 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('-') times = t.split(':') seconds = times[2] |
