[egenix-users] mxDateTime on pyPgSQL/PostgreSQL applies timezone?

M.-A. Lemburg mal at egenix.com
Thu Jan 13 10:04:38 CET 2011


Kingsley Turner wrote:
> Hi,
> 
> I'm confused as to what's going on with a PostgreSQL "timestamp" type
> converted back to string.
> 
> Selecting my timestamp field from PostgreSQL via psql gives:
> 
>    2011-01-12 21:54:11
> 
> 
> Yet in my code, when I str() or mx.DateTime.ISO.strUTC() the mx.DateTime
> representation of the field returned by pyPgSQL, I get
> 
>    2011-01-13 08:01:04.00
>    2011-01-13 08:54:11+0000
> 
> 
> I'm currently in UTC+11 (10+summer)
> 
> Any suggestions as to what might be happening here?
> 
> When I first connect to PostgreSQL, I always SET TIMEZONE UTC.

mxDateTime stores the date/time value depending on what you
pass to the constructor. It does not manipulate the value,
but does apply timezone conversions in case you tell it to
convert the time to UTC.

You would have to track down how PyPgSQL creates the mxDateTime
instances to tell whether the wrong constructor is being used
or whether PyPgSQL itself converts the stored UTC time value
to local time.

I am a bit confused about the two examples you gave, since
they should not differ in the minute and seconds values.
The first appears to point to a different database row.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 13 2011)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the egenix-users mailing list