Yesterday I switched my Linux machines to use clockspeed 0.62 and therefore had to
switch to the right/EST5EDT timezone.
Today my client calls rather upset that lots of data has disappeared from his
So while I have found and fixed a bunch of timezone conversion problems in my code,
I'm stumped by DateTime.strftime().
I'm working with Zope 2.6.0 but the code is the same in 2.7.0b2
Basically, I get this situation:
>>> y = DateTime.DateTime(dx)
>>> y.strftime("%a %b. %d")
'Sun Nov. 30'
>>> y.strftime("%a %b %d %H:%M:%S")
'Sun Nov 30 23:59:38'
So, the DateTime object knows the correct year, month and day, it's mishandling of
'diff' in strftime is a problem. I can't quite figure out what the regex does in the
below, but diff is 22 seconds off from the "regular timezone offset". That's will be
the divide by 36.
The timezone offset that _tzoffset calculates is wrong:
>>> DateTime._tzoffset(y._tz, y._t)
(but it should be 'right/EST5EDT')
What's the best way for me to fix this? I'll submit a patch if I can get a clue.
Btw, the timezone right/EST5EDT isn't in DateTime's timezone listing. Shouldn't Zope
get this data from Python?
I'll remark that Python doesn't know about the 'correct' offset either.
>>> import time
Well now I'm stuck, I've set /etc/localtime and /usr/share/zoneinfo/posixrules
and "date" returns the correct time.
However even forcing TZ with Python 2.3 doesn't work correctly.
sh-2.05b$ TZ="right/EST5EDT" python2.3
Python 2.3.2 (#2, Nov 6 2003, 10:44:39)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import time
How does time.localtime() know the correct timezone offset, but time.timezone is not
>>> time.localtime(); os.system('date')
(2003, 12, 1, 12, 55, 25, 0, 335, 0)
Mon Dec 1 12:55:25 EST 2003
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),
return strftime(format, safegmtime(self.timeTime() + diff))
Brad Clements, [EMAIL PROTECTED] (315)268-1000
http://www.murkworks.com (315)268-9812 Fax
http://www.wecanstopspam.org/ AOL-IM: BKClements
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -