Re: psycopg2: parsing timestamps with odd time zones
Karsten Hilbert <[email protected]> Wed, 19 May 2010 15:41:46 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, May 19, 2010 at 03:36:42PM +0200, Karsten Hilbert wrote:
> 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
Remove this "print", of course.
Also, the doc string of register_tstz_w_secs could be
improved:
If you encounter "unable to parse time" or "time zone offset XXX
is not a whole number of minutes" on a perfectly valid
timestamp you likely want to try this type caster. It truncates
the seconds from the time zone data and retries casting
the timestamp. Note that this will generate timestamps
which are **inaccurate** by the number of seconds truncated
(unless the seconds were 00).
Thanks,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346