Commit 69f0a937 authored by Paul Winkler's avatar Paul Winkler

Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

parent d3ad78e1
...@@ -8,6 +8,9 @@ Zope Changes ...@@ -8,6 +8,9 @@ Zope Changes
Bugs fixed Bugs fixed
- Launchpad #267545: DateTime(DateTime()) now preserves the
correct hour
- Launchpad #245649: the Products package is now a proper - Launchpad #245649: the Products package is now a proper
"namespace package" under the rules specified by setuptools. "namespace package" under the rules specified by setuptools.
......
...@@ -712,11 +712,8 @@ class DateTime: ...@@ -712,11 +712,8 @@ class DateTime:
if isinstance(arg, DateTime): if isinstance(arg, DateTime):
""" Construct a new DateTime instance from a given DateTime instance """ """ Construct a new DateTime instance from a given DateTime instance """
t = arg.timeTime() t = arg.timeTime()
tz = arg.timezone()
ms = (t - math.floor(t))
s,d = _calcSD(t) s,d = _calcSD(t)
yr,mo,dy,hr,mn,sc = gmtime(t)[:6] yr,mo,dy,hr,mn,sc,tz = arg.parts()
sc = sc + ms
elif isinstance(arg, (unicode, str)) and arg.lower() in self._tzinfo._zidx: elif isinstance(arg, (unicode, str)) and arg.lower() in self._tzinfo._zidx:
# Current time, to be displayed in specified timezone # Current time, to be displayed in specified timezone
......
...@@ -296,8 +296,10 @@ class DateTimeTests(unittest.TestCase): ...@@ -296,8 +296,10 @@ class DateTimeTests(unittest.TestCase):
def testCopyConstructor(self): def testCopyConstructor(self):
d = DateTime('2004/04/04') d = DateTime('2004/04/04')
self.assertEqual(DateTime(d), d) self.assertEqual(DateTime(d), d)
d = DateTime('1999/04/12') self.assertEqual(str(DateTime(d)), str(d))
self.assertEqual(DateTime(d), d) d2 = DateTime('1999/04/12 01:00:00')
self.assertEqual(DateTime(d2), d2)
self.assertEqual(str(DateTime(d2)), str(d2))
def testCopyConstructorPreservesTimezone(self): def testCopyConstructorPreservesTimezone(self):
# test for https://bugs.launchpad.net/zope2/+bug/200007 # test for https://bugs.launchpad.net/zope2/+bug/200007
...@@ -308,8 +310,10 @@ class DateTimeTests(unittest.TestCase): ...@@ -308,8 +310,10 @@ class DateTimeTests(unittest.TestCase):
self.assertEqual(DateTime(d).timezone(), d.timezone()) self.assertEqual(DateTime(d).timezone(), d.timezone())
d2 = DateTime('2008/04/25 12:00:00 EST') d2 = DateTime('2008/04/25 12:00:00 EST')
self.assertEqual(DateTime(d2).timezone(), d2.timezone()) self.assertEqual(DateTime(d2).timezone(), d2.timezone())
self.assertEqual(str(DateTime(d2)), str(d2))
d3 = DateTime('2008/04/25 12:00:00 PST') d3 = DateTime('2008/04/25 12:00:00 PST')
self.assertEqual(DateTime(d3).timezone(), d3.timezone()) self.assertEqual(DateTime(d3).timezone(), d3.timezone())
self.assertEqual(str(DateTime(d3)), str(d3))
def testRFC822(self): def testRFC822(self):
......
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