Commit e29bbfd4 authored by Lennart Regebro's avatar Lennart Regebro

Merged Zope/branches/regebro-strftime_1127 28397:28400; bugfix for issue #1127

parent d49c0671
......@@ -36,6 +36,8 @@ Zope Changes
Statistics view in the ZMI
Bugs fixed
- Collector #1127: strftime did not take timezone into account.
- ZPublisher: changed some hardcoded 'latin1' arguments to 'iso-8859-15'
since latin1 is obsolete.
......
......@@ -1476,11 +1476,7 @@ class DateTime:
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):
......
......@@ -7,6 +7,7 @@ import os
import time
import unittest
from DateTime.DateTime import _findLocalTimeZoneName
from DateTime import DateTime
try:
......@@ -338,6 +339,16 @@ class DateTimeTests(unittest.TestCase):
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():
......
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