Re: [Zope-dev] DateTime stftime and TAI based timezone is broken or is it?

2003-12-03 Thread Brad Clements
On 2 Dec 2003 at 13:39, Jamie Heilman wrote:

   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'
 
 Lovely.  Its always bugged me that DateTime carried all its own zone
 information, but I guess even the datetime python modules punt in this
 regard.  What I'm currious to know is how this caused problems for
 you, or your clients.  I'd like to avoid those problems myself if I
 can help it.

My legacy site has a lot of dtml-var somedatetimeobject fmt=%a %b %d

this writes out the wrong day, because somedatetimeobject is just like you show above.

Also, I get different results instantiating a DateTime object with a string, vs. parts 
DateTime(y,m,d,h,m,s) vs. DateTime('-MM-DD HH:MM:SS')

Why can't Zope just dynamically load the tzfile data as appropriate from the system if 
it 
can? 


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


Re: [Zope-dev] DateTime stftime and TAI based timezone is broken or is it?

2003-12-02 Thread Jamie Heilman
Brad Clements wrote:
 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..

Interesting, I've been using right/US/Pacific myself for ages but I
never experienced any pain from it.  Then again, I never noticed
DateTime was getting stuff wrong until you pointed this out.
 
  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'

Lovely.  Its always bugged me that DateTime carried all its own zone
information, but I guess even the datetime python modules punt in this
regard.  What I'm currious to know is how this caused problems for
you, or your clients.  I'd like to avoid those problems myself if I
can help it.

-- 
Jamie Heilman http://audible.transient.net/~jamie/
Paranoia is a disease unto itself, and may I add, the person standing
 next to you may not be who they appear to be, so take precaution.
-Sathington Willoughby

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


[Zope-dev] DateTime stftime and TAI based timezone is broken or is it?

2003-12-01 Thread Brad Clements
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 )