[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnumed-devel] psycopg2: parsing timestamps with odd time zones
From: |
Karsten Hilbert |
Subject: |
[Gnumed-devel] psycopg2: parsing timestamps with odd time zones |
Date: |
Wed, 19 May 2010 15:36:42 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hello all,
apparently, the exception thrown by Python when failing to
parse time zones with seconds in them has changed. It used
to be
"DataError: unable to parse time"
but now is the more specific:
"ValueError: time zone offset XXXX is not a whole number of minutes"
To fix that we need to (re-)place this code in extras.py:
# safe management of times with a non-standard time zone
def _convert_tstz_w_secs(s, cursor):
try:
print s
return DATETIME(s, cursor)
except (DataError, ), exc:
if exc.message != "unable to parse time":
raise
if regex.match('(\+|-)\d\d:\d\d:\d\d', s[-9:]) is None:
raise
except (ValueError, ), exc:
if "time zone offset" not in exc.message:
raise
if "is not a whole number of minutes" not in exc.message:
raise
if regex.match('(\+|-)\d\d:\d\d:\d\d', s[-9:]) is None:
raise
# parsing doesn't succeed even if seconds are ":00" so truncate in any case
return DATETIME(s[:-3], cursor)
Thanks,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnumed-devel] psycopg2: parsing timestamps with odd time zones,
Karsten Hilbert <=