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:

>>> dx
'2003-12-01 00:00:00'
>>> y = DateTime.DateTime(dx)
>>> y
>>> y.strftime("%a %b. %d")
'Sun Nov. 30'
>>> y.strftime("%a %b %d %H:%M:%S")
'Sun Nov 30 23:59:38'
>>> y.Time()

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 
lost in 
the divide by 36. 

The timezone offset that _tzoffset calculates is wrong:

>>> DateTime._tzoffset(y._tz, y._t)


>>> y._tz

(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
>>> time.tzname
('EST', 'EDT')
>>> time.timezone

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
>>> os.environ['TZ']
>>> import time
>>> time.timezone
>>> time.tzname
('EST', 'EDT')
>>> time.tzset()
>>> time.tzname
('EST', 'EDT')
>>> time.timezone

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                          (315)268-9812 Fax                   AOL-IM: BKClements

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to