Commit f3fdd7d1 authored by Jérome Perrin's avatar Jérome Perrin

hack: DateTime.latestTime patch for 2013/03/31

parent 482f2f41
......@@ -248,6 +248,26 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()):
DateTimeKlass._parse = DateTime_parse
def DateTime_latestTime(self):
"""Return a new DateTime object that represents the latest
possible time (in whole seconds) that still falls within
the current object\'s day, in the object\'s timezone context.
Patched to return a date in the "natural time zone" when called on the day
of DST change.
An example problematic day is 2013/03/31, where DST switched at 2h00
2013/03/31 00:00:00 is GMT+1 but 2013/03/31 23:59:59 is GMT+2
The default behaviour of this method would be to return 2013/03/31 23:59:59
still in GMT+1, which is 22h59 local time.
"""
if self._hour == self._minute == self._second == 0:
return self.__class__(self._year,self._month,self._day,
23,59,59)
return self.__class__(self._year,self._month,self._day,
23,59,59,self._tz)
DateTimeKlass.latestTime = DateTime_latestTime
if __name__ == '__main__':
for i in ('2007/01/02 12:34:56.789',
'2007/01/02 12:34:56.789 GMT+0200',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment