mxDateTime timestamps with locale active
Karsten Hilbert <[email protected]> Tue, 25 May 2010 08:53:03 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello, would anyone be interested in commenting on the below ? The problem ist that the ISO format does allow for "," and "." while PostgreSQL will not handle the "," case. Which is why the below code is translating "," to "." when quoting mxDateTime instances. Thanks so much, Karsten On Wed, May 19, 2010 at 11:11:30PM +0200, Karsten Hilbert wrote: > Date: Wed, 19 May 2010 23:11:30 +0200 > From: Karsten Hilbert <[email protected]> > To: psycopg-IAPFreCvJWPBWskQ1e/[email protected] > Subject: Re: [Psycopg] psycopg2: parsing timestamps with odd time zones > User-Agent: Mutt/1.5.20 (2009-06-14) > > Hello Daniele, hello Frederico, > > thanks for making psycopg2 better from release to release ! > > While we are in the mood shall we consider another minor > glitch ? ;-) > > "qouting mxDateTime objects into timestamps while locale is ative" > > GNUmed is using this code to get by: > > > class cAdapterMxDateTime(object): > > def __init__(self, dt): > if dt.tz == '???': > _log.info('[%s]: no time zone string available in (%s), assuming local time zone', self.__class__.__name__, dt) > self.__dt = dt > > def getquoted(self): > # under some locale settings the mx.DateTime ISO formatter > # will insert "," into the ISO string, > # while this is allowed per the ISO8601 spec PostgreSQL > # cannot currently handle that, > # so map those "," to "." to make things work: > return mxDT.ISO.str(self.__dt).replace(',', '.') > > > I would appreciate discussion of this and perhaps inclusion > in psycopg2 ... > > Karsten > -- > GPG key ID E4071346 @ wwwkeys.pgp.net > E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346 > _______________________________________________ > Psycopg mailing list > Psycopg-IAPFreCvJWPBWskQ1e/[email protected] > http://lists.initd.org/mailman/listinfo/psycopg -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346