Ron Bickers wrote at 2005-1-30 20:42 -0500:
... What do you get when you try my examples? You only used your local timezone, which works fine for me too, but it doesn't work when I'm trying to use a different timezone than my own.
now=DateTime('GMT') now DateTime('2005/01/31 18:11:23.211 GMT') now.strftime('%H') '18'
Note, that my local timezone is "GMT+1". Thus, it works for me also in a different timezone.
Also, according to notes in the bug I referenced, it looks like the behavior may have changed starting with 2.7.4.
Okay, can only speak for 2.7.2. -- Dieter
On Monday 31 January 2005 01:13 pm, Dieter Maurer wrote:
Thus, it works for me also in a different timezone.
Also, according to notes in the bug I referenced, it looks like the behavior may have changed starting with 2.7.4.
Okay, can only speak for 2.7.2.
2.7.3 gives the same thing you're reporting, but 2.7.4 does not. What does DateTime('GMT').strftime('%Z') return for you? Both 2.7.3 and 2.7.4 return my local timezone, even though 2.7.3 returns the correct hour for GMT. -- Ron Bickers Logic Etc, Inc.
Ron Bickers wrote at 2005-1-31 15:37 -0500:
... What does DateTime('GMT').strftime('%Z') return for you? Both 2.7.3 and 2.7.4 return my local timezone, even though 2.7.3 returns the correct hour for GMT.
I only now understand your problem (as I am not familiar with US timezones). Looking at the code of "DateTime.strftime" (note 2.7.2), it calls "time.strftime" and this does not know anything about a timezope different from the standard one. This means: everything is correct with the exception of the timezone info. There are two approaches: * Do not use "time.strftime" * Code the "%Z" appropriately before the format is passed on to "time.strftime" and after the call replace the code with the timezone of the "DateTime". -- Dieter
On Tuesday 01 February 2005 12:44 pm, Dieter Maurer wrote:
This means: everything is correct with the exception of the timezone info.
Not in 2.7.4; the time returned by strftime is always in the local timezone, so %Z remains correct, but there's no way to get the hour of another timezone from it.
There are two approaches:
* Do not use "time.strftime"
That's the approach I took.
* Code the "%Z" appropriately before the format is passed on to "time.strftime" and after the call replace the code with the timezone of the "DateTime".
That would work in Zope prior to 2.7.4, but not anymore. Thanks for your time. -- Ron
participants (2)
-
Dieter Maurer -
Ron Bickers