[Zope-dev] Possible DateTime timezone-related regression in Zope 2.12

Tres Seaver tseaver at palladion.com
Fri Mar 5 13:56:28 EST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Aspeli wrote:
> Hi,
> 
> We have a failing test in plone.app.dexterity 1.0a7. This is simply 
> trying to compare two dates:
> 
>      >>> from DateTime import DateTime
>      >>> DateTime() > DateTime(md.CreationDate())
>      True
> 
> At least here in Australia, the second test fails. Right now, the 
> following expressions are:
> 
>      DateTime(): DateTime('2010/01/10 11:20:24.718203 GMT+8')
>      md.CreationDate(): '2010-01-10 11:19:57'
>      DateTime(md.CreationDate()): DateTime('2010/01/10 11:19:57 GMT+0')
> 
> On Zope 2.10, it's a different story:
> 
>     DateTime(): DateTime('2010/01/10 11:34:01.508 GMT+8')
>     md.CreationDate(): '2010-01-10 11:24:42'
>     DateTime(md.CreationDate()): DateTime('2010/01/10 11:24:42 GMT+8')
> 
> Andi Zeidler looked into it briefly, and said the following:
> 
> imho, this is due a bug in `DateTime` 2.12.0.  the newer version behaves 
> differently when it's initialized via a string representation of a date 
> — it interprets the given date to be GMT while before it was taken to be 
> from your local time zone:
> 
>   $ cd ~/plone/coredev/branches
>   $ cat foo.py
>   from DateTime import DateTime
>   print DateTime('2010-01-09 00:34:37')
>   $ 3.3/bin/zopepy foo.py
>   2010/01/09 00:34:37 GMT+1
>   $ 4.0/bin/zopepy foo.py
>   2010/01/09 00:34:37 GMT+0
> 
> so in your test, `DateTime(md.CreationDate())` will always be the 
> current time, but with an implicitly added 'GMT+0' while `DateTime()` 
> will be the current time in your local time zone.  so if i'm not 
> mistaken, on plone 4.0 the test with fail for you an me (in 'GMT+x' time 
> zones) and pass in the u.s.  fun! :)
> 
> Does anyone know if this change was deliberate, or what may have happened?

Why would you be parsing the 'CreationDate' return value (a string)
instead of just using the 'created' value (already a DateTime)?


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuRU9sACgkQ+gerLs4ltQ4ItQCgpgfgzo9SKBjx4cXVxPnps4h6
8RAAoKrV/Z2K+WLPBzuWd+XhZHlA7pRW
=CryU
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list