[Zope-Checkins] SVN: Zope/branches/regebro-strftime_1127/lib/python/DateTime/ Fixed issue #1127

Lennart Regebro regebro at nuxeo.com
Mon Nov 8 11:49:48 EST 2004


Log message for revision 28400:
  Fixed issue #1127

Changed:
  U   Zope/branches/regebro-strftime_1127/lib/python/DateTime/DateTime.py
  U   Zope/branches/regebro-strftime_1127/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/regebro-strftime_1127/lib/python/DateTime/DateTime.py
===================================================================
--- Zope/branches/regebro-strftime_1127/lib/python/DateTime/DateTime.py	2004-11-08 16:25:36 UTC (rev 28399)
+++ Zope/branches/regebro-strftime_1127/lib/python/DateTime/DateTime.py	2004-11-08 16:49:48 UTC (rev 28400)
@@ -1476,11 +1476,7 @@
 
     def strftime(self, format):
         # Format the date/time using the *current timezone representation*.
-        diff = _tzoffset(self._tz, self._t)
-        format = re.sub('(^\|[^%])%z',
-                               '\\1%+05d' % (diff / 36),
-                               format)
-        return strftime(format, safegmtime(self.timeTime() + diff))
+        return strftime(format, safelocaltime(self.timeTime()))
 
     # General formats from previous DateTime
     def Date(self):

Modified: Zope/branches/regebro-strftime_1127/lib/python/DateTime/tests/testDateTime.py
===================================================================
--- Zope/branches/regebro-strftime_1127/lib/python/DateTime/tests/testDateTime.py	2004-11-08 16:25:36 UTC (rev 28399)
+++ Zope/branches/regebro-strftime_1127/lib/python/DateTime/tests/testDateTime.py	2004-11-08 16:49:48 UTC (rev 28400)
@@ -7,6 +7,7 @@
 import time
 import unittest
 
+from DateTime.DateTime import _findLocalTimeZoneName
 from DateTime import DateTime
 
 try:
@@ -338,6 +339,16 @@
         except DateTime.TimeError:
             self.fail('Zope Collector issue #484 (negative time bug): '
                       'TimeError raised')
+    
+    def testStrftimeTZhandling(self):
+        '''strftime timezone testing'''
+        # This is a test for collector issue #1127
+        format = '%Y-%m-%d %H:%M %Z'
+        dt = DateTime('Wed, 19 Nov 2003 18:32:07 -0215')
+        dt_string = dt.strftime(format)
+        dt_local = dt.toZone(_findLocalTimeZoneName(0))
+        dt_localstring = dt_local.strftime(format)
+        self.assertEqual(dt_string, dt_localstring)
 
 
 def test_suite():



More information about the Zope-Checkins mailing list