Ticket #5376 (closed Bug: worksforme)

Opened 6 years ago

Last modified 5 years ago

toLocalizedTime changes timezone representation of the passed DateTime object

Reported by: naro Owned by: hannosch
Priority: minor Milestone: 2.5.4
Component: Internationalization Keywords:
Cc:

Description

ulocalized_time method is using

time = DateTime(time)

call to ensure passed time is DateTime object. This may cause timezone change in case of daylight saving time. Please look to the following example:

>>> now = DateTime()
>>> now
DateTime('2006/03/22 20:41:02.370 GMT+1')
>>> now + 100
DateTime('2006/06/30 20:41:02.370 GMT+1')
>>> DateTime(now+100)
DateTime('2006/06/30 21:41:02.370 GMT+2')

Test:

    def testDateTimeArgDaylight(self):
        value = self.script(DateTime('Mar 9, 1997 1:45pm')+60,
                            long_format=True)
        # TranslationServiceTool falls back to time formats in site properties
        # because PTS isn't installed
        self.assertEquals(value, '1997-05-08 13:45')

Change History

comment:1 Changed 6 years ago by hannosch

  • Milestone set to 2.1.x

comment:2 Changed 5 years ago by hannosch

  • Status changed from new to closed
  • Resolution set to worksforme

I'm not sure what the actual expected bahaviour should be here. Right now we don't handle any time zone information in Plone at all. So all times are expected to be in the timezone of the server. When adding hundreds days to a time is passing a daylight saving change, I'd expect the script to recognize that and return the new time in the new timezone.

Note: See TracTickets for help on using tickets.