Skip to content

Commit

Permalink
Fixed issue #1127
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Nov 8, 2004
1 parent 9bd2163 commit 4f48e52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/python/DateTime/DateTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,11 +1476,7 @@ def _upgrade_old(self):

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):
Expand Down
11 changes: 11 additions & 0 deletions lib/python/DateTime/tests/testDateTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
import unittest

from DateTime.DateTime import _findLocalTimeZoneName
from DateTime import DateTime

try:
Expand Down Expand Up @@ -338,6 +339,16 @@ def test_calcTimezoneName(self):
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():
Expand Down

0 comments on commit 4f48e52

Please sign in to comment.