Zope 2.11.1 DateTime - strftime uses current date/time
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Undecided
|
Tres Seaver |
Bug Description
I recently upgraded a Zope instance from 2.9.3 to 2.11.1.
Some odd behaviour occurs when calling the strftime method on DateTime instances created in 2.9.3 or earlier:
The date that is formatted is always the current date and time, not that stored in the DateTime object.
For me, this has been on Date properties and saving the properties via the manage_
=============
This problem is caused by the changes in DateTime between Zope 2.10 and 2.11. The DateTime object now calculates and stores a date in micro-seconds and stores that on the DateTime object using an attribute _micros.
The ZODB uses the pickler to load DateTime objects.
First the pickler creates a new DateTime object using a single parameter None, which creates a new DateTime and initialises it to the currrent time. The DateTime dictionary is constructed, including the _micros attribute.
The the pickler loads the object dictionary using the values stored in the ZODB. The stored values do not include a _micros attribute, so the _micros attribute is not overridden (thus it includes the current time).
If you retrieve the DateTime objects directly or use the str() method, the correct values are returned. However, if you use a method which uses the underlying _micros value such as comparison functions or asdatetime(), you get an incorrect value.
description: | updated |
Changed in zope2: | |
assignee: | nobody → tseaver |
status: | New → Fix Committed |
Changed in zope2: | |
status: | Fix Committed → Fix Released |
How to reproduce in detail?