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 
database, 
etc..

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
DateTime('2003/12/01')
>>> y.strftime("%a %b. %d")
'Sun Nov. 30'
>>> y.strftime("%a %b %d %H:%M:%S")
'Sun Nov 30 23:59:38'
>>> y.Time()
'00:00:00'

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 
code 
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)
-18000

Because 

>>> y._tz
'US/Eastern'

(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
18000

Well now I'm stuck, I've set /etc/localtime and /usr/share/zoneinfo/posixrules 
correctly, 
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']
'right/EST5EDT'
>>> import time
>>> time.timezone
18000
>>> time.tzname
('EST', 'EDT')
>>> time.tzset()
>>> time.tzname
('EST', 'EDT')
>>> time.timezone
18000

How does time.localtime() know the correct timezone offset, but time.timezone is not 
correct?

>>> time.localtime(); os.system('date')
(2003, 12, 1, 12, 55, 25, 0, 335, 0)
Mon Dec  1 12:55:25 EST 2003


-----

DateTime.py

    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))

-- 
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]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to