Commit 0974da5c authored by Laurence Rowe's avatar Laurence Rowe

Revert ISO8601 interpretation to previously broken behaviour (assume GMT...

Revert ISO8601 interpretation to previously broken behaviour (assume GMT rather than local time as per spec)
parent 735cd389
......@@ -451,6 +451,9 @@ class DateTime:
</PRE>
See http://en.wikipedia.org/wiki/ISO_8601 for full specs.
Note that the Zope DateTime parser assumes timezone naive ISO
strings to be in UTC rather than local time as specified.
- If the DateTime function is invoked with a single Numeric
argument, the number is assumed to be a floating point value
......@@ -1798,14 +1801,12 @@ class DateTime:
if fields['signal'] or fields['Z']:
tznaive = False
tz = 'GMT%+03d%02d' % (hour_off, min_off)
else:
tznaive = True
# Figure out what time zone it is in the local area
# on the given date.
ms = seconds - math.floor(seconds)
x = _calcDependentSecond2(year,month,day,hour,minute,seconds)
tz = self._calcTimezoneName(x, ms)
# Differ from the specification here. To preserve backwards
# compatibility assume a default timezone == UTC.
tz = 'GMT%+03d%02d' % (hour_off, min_off)
return year, month, day, hour, minute, seconds, tz, tznaive
......
......@@ -262,21 +262,22 @@ class DateTimeTests(unittest.TestCase):
def testISO8601(self):
# ISO8601 reference dates
ref0 = DateTime('2002/5/2 8:00am')
ref0 = DateTime('2002/5/2 8:00am GMT')
ref1 = DateTime('2002/5/2 8:00am US/Eastern')
ref2 = DateTime('2006/11/6 10:30')
ref3 = DateTime('2004/06/14 14:30:15 GMT-3')
ref4 = DateTime('2006/01/01')
ref5 = DateTime('2002/5/2 8:00am GMT')
# Basic tests
# this is timezone naive and should be interpreted in the local timezone
# Though this is timezone naive and according to specification should
# be interpreted in the local timezone, to preserve backwards
# compatibility with previously expected behaviour.
isoDt = DateTime('2002-05-02T08:00:00')
self.assertEqual(ref0, isoDt)
isoDt = DateTime('2002-05-02T08:00:00Z')
self.assertEqual(ref5, isoDt)
self.assertEqual(ref0, isoDt)
isoDt = DateTime('2002-05-02T08:00:00+00:00')
self.assertEqual(ref5, isoDt)
self.assertEqual(ref0, isoDt)
isoDt = DateTime('2002-05-02T08:00:00-04:00')
self.assertEqual(ref1, isoDt)
isoDt = DateTime('2002-05-02 08:00:00-04:00')
......@@ -310,7 +311,7 @@ class DateTimeTests(unittest.TestCase):
# Bug 2191: timezones with only one digit for hour
isoDt = DateTime('20020502T080000+0')
self.assertEqual(ref5, isoDt)
self.assertEqual(ref0, isoDt)
isoDt = DateTime('20020502 080000-4')
self.assertEqual(ref1, isoDt)
isoDt = DateTime('20020502T080000-400')
......
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