[Zope] Still. Zope date datatype and TimeZone formatting problems.

Tino Wildenhain tino at wildenhain.de
Mon May 23 03:07:56 EDT 2005


Am Sonntag, den 22.05.2005, 13:01 -0500 schrieb Felipe Barousse Boue:
> Zopistas:
> 
> I am experiencing the same problem you described by Mr. Hong Yuan in his
> post a few from last March.  I have Zope 2.7.4, python 2.3.4 and
> PostgreSQL 8.0 and psycopg as DB adapter.
> 
> All my dates stores in postgresql are WITHOUT timezone and my linux is
> set for the "America/Mexico City" time zone. All works fine at the OS
> and python level but not within Zope, it behaves as Mr. Hong Yuan
> describes in the post.
> 
> I have noticed that Zope, when getting the data coming from postgresql
> (the date) always takes it to be at midnight in GMT time zone. 
> 
> While formatting the date for presentation, it doesn't take into account
> the OS TZ settings, it just assumes data (from postgresql) is at
> midnight in GMT and mangles it.

Of course. I wonder why it should? Otoh, did you try to give the
timezone you want when you select the data? 

> If the TZ variable is set on the zope.conf file, it actually adds hours
> to the date (as like moving east), having first during the day having
> the "date ok" but a wrong time and, later on the day, the date goes
> wrong because of that timezone difference.

I assume this setting is mainly for zope generated datetime objects,
not something you read from a DB.

> If the TZ is not set in the zope.conf file it substracts hours from the
> date data from postgresql, effectively moving the date on day before,
> because it assumed midnight GMT.
> 
> Doing further experiments I have noticed that when the data type passed 
> to Zope is "date" (not "datetime" or "timespamp", only date) then Zope 
> misbehaves with the TZ, assuming it is on GMT and not taking into
> account the overall system (Operating system) time zone settings.

Well, databases are often on a seperate host. How should zope guess in
this case? If it would, I guess someone else would complaint ;)

> I have seen posts discussing this issue as far back as 2001. Has it been
> solved already ?   Is it worth getting into the Zope code and trying to 
> fix it and submit a patch ? Or its already deprecated ? or...?
> 
> I believe it is still a huge bug the the Zope/Python date time handling
> routines, I am correct with this appreciation?

Well, zopes DateTime implemenataion has some (serious) limits. But I 
dont think it should really be blamed for the above problems.
Maybe some workarounds can be made in the psycopg driver.

What btw. happens if you use mxdatetime instead of the zope builtin?
Psycopg has this as configuration option.

Regards
Tino




More information about the Zope mailing list