[Zope-Checkins] SVN: Zope/branches/2.9/ Merged the
slinkp-datetime-200007 branch: fix the
DateTime(anotherDateTime) constructor to preserve timezones.
Paul Winkler
slinkp at gmail.com
Mon Apr 28 17:22:53 EDT 2008
Log message for revision 85837:
Merged the slinkp-datetime-200007 branch: fix the DateTime(anotherDateTime) constructor to preserve timezones.
Changed:
U Zope/branches/2.9/configure
U Zope/branches/2.9/doc/CHANGES.txt
U Zope/branches/2.9/lib/python/DateTime/DateTime.py
U Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py
-=-
Modified: Zope/branches/2.9/configure
===================================================================
--- Zope/branches/2.9/configure 2008-04-28 21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/configure 2008-04-28 21:22:09 UTC (rev 85837)
@@ -12,13 +12,13 @@
# Place the optimal target version number for Zope (as returned by sys.version)
# below
-TARGET="2.4.4"
+TARGET="2.4.5"
# Order a list of "acceptable" python version numbers (as returned by
# sys.version) below in "best" to "worst" order, not including the
# target version. Up to six acceptable python versions are allowed.
# Do not include the target version number in this list!
-ACCEPTABLE="2.4.2 2.4.3"
+ACCEPTABLE="2.4.4 2.4.2 2.4.3"
# provide the executable names for all the acceptable versions
# (and the target version) below
Modified: Zope/branches/2.9/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.9/doc/CHANGES.txt 2008-04-28 21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/doc/CHANGES.txt 2008-04-28 21:22:09 UTC (rev 85837)
@@ -8,6 +8,9 @@
Bugs fixed
+ - Launchpad #200007: DateTime(anotherDateTime) now preserves the
+ timezone.
+
- Launchpad #143813: zopectl now exits non-zero when
child processes fail.
Modified: Zope/branches/2.9/lib/python/DateTime/DateTime.py
===================================================================
--- Zope/branches/2.9/lib/python/DateTime/DateTime.py 2008-04-28 21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/lib/python/DateTime/DateTime.py 2008-04-28 21:22:09 UTC (rev 85837)
@@ -712,12 +712,11 @@
if isinstance(arg, DateTime):
""" Construct a new DateTime instance from a given DateTime instance """
t = arg.timeTime()
- lt = safelocaltime(t)
- tz = self.localZone(lt)
+ tz = arg.timezone()
ms = (t - math.floor(t))
s,d = _calcSD(t)
- yr,mo,dy,hr,mn,sc=lt[:6]
- sc=sc+ms
+ yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
+ sc = sc + ms
elif isinstance(arg, (unicode, str)) and arg.lower() in self._tzinfo._zidx:
# Current time, to be displayed in specified timezone
Modified: Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py
===================================================================
--- Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py 2008-04-28 21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py 2008-04-28 21:22:09 UTC (rev 85837)
@@ -299,6 +299,19 @@
d = DateTime('1999/04/12')
self.assertEqual(DateTime(d), d)
+ def testCopyConstructorPreservesTimezone(self):
+ # test for https://bugs.launchpad.net/zope2/+bug/200007
+ # This always worked in the local timezone, so we need at least
+ # two tests with different zones to be sure at least one of them
+ # is not local.
+ d = DateTime('2004/04/04')
+ self.assertEqual(DateTime(d).timezone(), d.timezone())
+ d2 = DateTime('2008/04/25 12:00:00 EST')
+ self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+ d3 = DateTime('2008/04/25 12:00:00 PST')
+ self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+
+
def testRFC822(self):
'''rfc822 conversion'''
dt = DateTime('2002-05-02T08:00:00+00:00')
More information about the Zope-Checkins
mailing list