strptime and timezones

Tom Anderson twic at urchin.earth.li
Thu Aug 14 12:09:26 EDT 2008


On Wed, 13 Aug 2008, Christian Heimes wrote:

> Tom Anderson wrote:
>
>> Secondly, do you really have to do this just to parse a date with a 
>> timezone? If so, that's ridiculous.
>
> No, you don't. :) Download the pytz package from the Python package 
> index. It's *the* tool for timezone handling in Python. The time zone 
> definition are not part of the Python standard library because they 
> change every few of months. Stupid politicians ...

My problem has absolutely nothing to do with timezone definitions. In 
fact, it involves less timezone knowledge than the time package supplies! 
The wonderful thing about RFC 1123 timestamps is that they give the 
numeric value of their timezone, so you don't have to decode a symbolic 
one or anything like that. Knowing about timezones thus isn't necessary.

The problem is simply that the standard time package doesn't think that 
way, and always assumes that a time is in your local timezone.

That said, it does look like pytz might be able to parse RFC 1123 dates. 
Ill check it out.

tom

-- 
Come on thunder; come on thunder.



More information about the Python-list mailing list