[Zope-Checkins] SVN: Zope/trunk/ Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

2008-09-07 Thread Paul Winkler
Log message for revision 90920:
  Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct 
hour

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/DateTime/DateTime.py
  U   Zope/trunk/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2008-09-07 02:49:58 UTC (rev 90919)
+++ Zope/trunk/doc/CHANGES.txt  2008-09-07 19:50:10 UTC (rev 90920)
@@ -207,6 +207,9 @@
 
 Bugs Fixed
 
+  - Launchpad #267545: DateTime(DateTime()) now preserves the
+correct hour
+
   - Launchpad #262313: respect the 'Expand macros when editing' flag
 when editing a page template through the ZMI
 

Modified: Zope/trunk/lib/python/DateTime/DateTime.py
===
--- Zope/trunk/lib/python/DateTime/DateTime.py  2008-09-07 02:49:58 UTC (rev 
90919)
+++ Zope/trunk/lib/python/DateTime/DateTime.py  2008-09-07 19:50:10 UTC (rev 
90920)
@@ -586,11 +586,8 @@
 DateTime instance.
 
 t = arg.timeTime()
-tz = arg.timezone()
-ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
-sc = sc + ms
+yr,mo,dy,hr,mn,sc,tz = arg.parts()
 
 elif isinstance(arg, datetime):
 
yr,mo,dy,hr,mn,sc,numerictz,tznaive=self._parse_iso8601_preserving_tznaive(arg.isoformat())

Modified: Zope/trunk/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/trunk/lib/python/DateTime/tests/testDateTime.py2008-09-07 
02:49:58 UTC (rev 90919)
+++ Zope/trunk/lib/python/DateTime/tests/testDateTime.py2008-09-07 
19:50:10 UTC (rev 90920)
@@ -401,8 +401,10 @@
 def testCopyConstructor(self):
 d = DateTime('2004/04/04')
 self.assertEqual(DateTime(d), d)
-d = DateTime('1999/04/12')
-self.assertEqual(DateTime(d), d)
+self.assertEqual(str(DateTime(d)), str(d))
+d2 = DateTime('1999/04/12 01:00:00')
+self.assertEqual(DateTime(d2), d2)
+self.assertEqual(str(DateTime(d2)), str(d2))
 
 def testCopyConstructorPreservesTimezone(self):
 # test for https://bugs.launchpad.net/zope2/+bug/27
@@ -413,8 +415,10 @@
 self.assertEqual(DateTime(d).timezone(), d.timezone())
 d2 = DateTime('2008/04/25 12:00:00 EST')
 self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+self.assertEqual(str(DateTime(d2)), str(d2))
 d3 = DateTime('2008/04/25 12:00:00 PST')
 self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+self.assertEqual(str(DateTime(d3)), str(d3))
 
 
 def testRFC822(self):

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.11/ Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

2008-09-07 Thread Paul Winkler
Log message for revision 90921:
  Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct 
hour

Changed:
  U   Zope/branches/2.11/doc/CHANGES.txt
  U   Zope/branches/2.11/lib/python/DateTime/DateTime.py
  U   Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/2.11/doc/CHANGES.txt
===
--- Zope/branches/2.11/doc/CHANGES.txt  2008-09-07 19:50:10 UTC (rev 90920)
+++ Zope/branches/2.11/doc/CHANGES.txt  2008-09-07 19:51:10 UTC (rev 90921)
@@ -16,6 +16,9 @@
 
   - integrated Hotfix-2008-08-12
 
+  - Launchpad #267545: DateTime(DateTime()) now preserves the
+correct hour
+
   - Launchpad #262313: respect the 'Expand macros when editing' flag
 when editing a page template through the ZMI
 

Modified: Zope/branches/2.11/lib/python/DateTime/DateTime.py
===
--- Zope/branches/2.11/lib/python/DateTime/DateTime.py  2008-09-07 19:50:10 UTC 
(rev 90920)
+++ Zope/branches/2.11/lib/python/DateTime/DateTime.py  2008-09-07 19:51:10 UTC 
(rev 90921)
@@ -586,11 +586,8 @@
 DateTime instance.
 
 t = arg.timeTime()
-tz = arg.timezone()
-ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
-sc = sc + ms
+yr,mo,dy,hr,mn,sc,tz = arg.parts()
 
 elif isinstance(arg, datetime):
 
yr,mo,dy,hr,mn,sc,numerictz,tznaive=self._parse_iso8601_preserving_tznaive(arg.isoformat())

Modified: Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:50:10 UTC (rev 90920)
+++ Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:51:10 UTC (rev 90921)
@@ -401,8 +401,10 @@
 def testCopyConstructor(self):
 d = DateTime('2004/04/04')
 self.assertEqual(DateTime(d), d)
-d = DateTime('1999/04/12')
-self.assertEqual(DateTime(d), d)
+self.assertEqual(str(DateTime(d)), str(d))
+d2 = DateTime('1999/04/12 01:00:00')
+self.assertEqual(DateTime(d2), d2)
+self.assertEqual(str(DateTime(d2)), str(d2))
 
 def testCopyConstructorPreservesTimezone(self):
 # test for https://bugs.launchpad.net/zope2/+bug/27
@@ -413,8 +415,10 @@
 self.assertEqual(DateTime(d).timezone(), d.timezone())
 d2 = DateTime('2008/04/25 12:00:00 EST')
 self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+self.assertEqual(str(DateTime(d2)), str(d2))
 d3 = DateTime('2008/04/25 12:00:00 PST')
 self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+self.assertEqual(str(DateTime(d3)), str(d3))
 
 
 def testRFC822(self):

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.10/ Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

2008-09-07 Thread Paul Winkler
Log message for revision 90922:
  Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct 
hour

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/DateTime/DateTime.py
  U   Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===
--- Zope/branches/2.10/doc/CHANGES.txt  2008-09-07 19:51:10 UTC (rev 90921)
+++ Zope/branches/2.10/doc/CHANGES.txt  2008-09-07 19:52:37 UTC (rev 90922)
@@ -24,6 +24,9 @@
 
   - integrated Hotfix-2008-08-12
 
+  - Launchpad #267545: DateTime(DateTime()) now preserves the
+correct hour
+
   - Launchpad #262313: respect the 'Expand macros when editing' flag
 when editing a page template through the ZMI
 

Modified: Zope/branches/2.10/lib/python/DateTime/DateTime.py
===
--- Zope/branches/2.10/lib/python/DateTime/DateTime.py  2008-09-07 19:51:10 UTC 
(rev 90921)
+++ Zope/branches/2.10/lib/python/DateTime/DateTime.py  2008-09-07 19:52:37 UTC 
(rev 90922)
@@ -704,11 +704,8 @@
 if isinstance(arg, DateTime):
  Construct a new DateTime instance from a given DateTime 
instance 
 t = arg.timeTime()
-tz = arg.timezone()
-ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
-sc = sc + ms
+yr,mo,dy,hr,mn,sc,tz = arg.parts()
 
 elif isinstance(arg, (unicode, str)) and arg.lower() in 
self._tzinfo._zidx:
 # Current time, to be displayed in specified timezone

Modified: Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:51:10 UTC (rev 90921)
+++ Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:52:37 UTC (rev 90922)
@@ -296,8 +296,10 @@
 def testCopyConstructor(self):
 d = DateTime('2004/04/04')
 self.assertEqual(DateTime(d), d)
-d = DateTime('1999/04/12')
-self.assertEqual(DateTime(d), d)
+self.assertEqual(str(DateTime(d)), str(d))
+d2 = DateTime('1999/04/12 01:00:00')
+self.assertEqual(DateTime(d2), d2)
+self.assertEqual(str(DateTime(d2)), str(d2))
 
 def testCopyConstructorPreservesTimezone(self):
 # test for https://bugs.launchpad.net/zope2/+bug/27
@@ -308,8 +310,10 @@
 self.assertEqual(DateTime(d).timezone(), d.timezone())
 d2 = DateTime('2008/04/25 12:00:00 EST')
 self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+self.assertEqual(str(DateTime(d2)), str(d2))
 d3 = DateTime('2008/04/25 12:00:00 PST')
 self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+self.assertEqual(str(DateTime(d3)), str(d3))
 
 
 def testRFC822(self):

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins