DateTime().strftime('%H:%M') sometimes adds 1 hour

Bug #191792 reported by Nico Grubert
2
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Undecided
Unassigned

Bug Description

Suppose we have a list of DateTime() instances like this:

dlist = [DateTime('2008/02/14 14:00:00 GMT+1'), \
         DateTime('2008/02/21 14:00:00 GMT+1'), \
         DateTime('2008/02/28 14:00:00 GMT+1'), \
         DateTime('2008/03/06 14:00:00 GMT+1'), \
         DateTime('2008/03/13 14:00:00 GMT+1'), \
         DateTime('2008/03/20 14:00:00 GMT+1'), \
         DateTime('2008/03/27 14:00:00 GMT+1'), \
         DateTime('2008/04/03 14:00:00 GMT+1'), \
         DateTime('2008/04/10 14:00:00 GMT+1'), \
         DateTime('2008/04/17 14:00:00 GMT+1'), \
         DateTime('2008/04/24 14:00:00 GMT+1'), \
         DateTime('2008/05/01 14:00:00 GMT+1'), \
         DateTime('2008/05/08 14:00:00 GMT+1'), \
         DateTime('2008/05/15 14:00:00 GMT+1'), \
         DateTime('2008/05/22 14:00:00 GMT+1'), \
         DateTime('2008/05/29 14:00:00 GMT+1')]

For some of these instances, the <DateTime() instance>.strftime('%H:%M') returns '15:00' even all instances in this list have '14:00'.

Here is an example (as an External Method for Zope) that demonstrate this DateTime bug:
# -----------------------------------------------------------------------------------------------------------------------------------
from DateTime import DateTime

def test(self):
    """ test
    """
    dlist = [DateTime('2008/02/14 14:00:00 GMT+1'), \
             DateTime('2008/02/21 14:00:00 GMT+1'), \
             DateTime('2008/02/28 14:00:00 GMT+1'), \
             DateTime('2008/03/06 14:00:00 GMT+1'), \
             DateTime('2008/03/13 14:00:00 GMT+1'), \
             DateTime('2008/03/20 14:00:00 GMT+1'), \
             DateTime('2008/03/27 14:00:00 GMT+1'), \
             DateTime('2008/04/03 14:00:00 GMT+1'), \
             DateTime('2008/04/10 14:00:00 GMT+1'), \
             DateTime('2008/04/17 14:00:00 GMT+1'), \
             DateTime('2008/04/24 14:00:00 GMT+1'), \
             DateTime('2008/05/01 14:00:00 GMT+1'), \
             DateTime('2008/05/08 14:00:00 GMT+1'), \
             DateTime('2008/05/15 14:00:00 GMT+1'), \
             DateTime('2008/05/22 14:00:00 GMT+1'), \
             DateTime('2008/05/29 14:00:00 GMT+1')]

    hm = '14:00'
    for d in dlist:
        if d.strftime('%H:%M') != '14:00':
            # -> ['DateError?', DateTime('2008/04/03 14:00:00 GMT+1'), '15:00']
            return ['DateError?', d, d.strftime('%H:%M')]
# -----------------------------------------------------------------------------------------------------------------------------------

Revision history for this message
Nico Grubert (nicogrubert-gmail) wrote :

This happens in Zope 2.9.6, 2.9.7, 2.9.8.
In Zope 2.10 everything works fine.

Revision history for this message
Andreas Jung (ajung) wrote :

This is a daylight saving issue. Since you specify the timezone, the daylight saving is taken into account when calling strtfime().

Changed in zope2:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.