Timezone
Choppy
Choppy_member at newsranger.com
Thu Apr 5 11:00:12 EDT 2001
In article <9ahdlo02al0 at news2.newsguy.com>, Alex Martelli says...
>
>"Choppy" <Choppy_member at newsranger.com> wrote in message
>news:3CHy6.1580$jz.135481 at www.newsranger.com...
>> I was wondering whether anyone knew if it's possible to change the
>timezone in a
>> Python script. The reason I ask is because my script is required to read
>dates
>> with their associated timezones and transform them into GMT. Python has a
>> funtion called gmtime() in their time module however it only transforms
>the time
>> based on the current local timezone. I solved this issue with C++ by
>setting an
>> environment variable "TZ" to the appropriate timezone and running the
>_tzset()
>> standard C library function to reset the current timezone. I don't see a
>way of
>> doing this in Python though. Any help would be appreciated.
>
>I don't see a way to have tzset() re-run in Python, either -- it
>appears to be run once when the time module is initialized, and
>that's it.
>
>If your date-string is in an ISO 8601 format, such as:
> YYYY-MM-DD HH:MM:SS[+-HH:MM]
>(where the part in brackets is the timezone), or if you
>can conveniently transform it to such format, then maybe
>the mxDateTime module, ISO submodule, ParseDateTimeUTC
>factory function, can fill your needs; or similarly, if
>your date strings are or can be conveniently put in
>ARPA format, the ARPA submodule -- and I quote:
>"""
>[Day, ]DD Mon YYYY HH:MM[:SS] ZONE
>
>where ZONE can be one of these: MDT, O, EDT, X, Y, CDT,
>UT, AST, GMT, PST, Z, V, CST, ADT, I, W, T, U, R, S, P,
>Q, N, EST, L, M, MST, K, H, E, F, G, D, PDT, B, C, UTC,
>A (the single letter ones being military time zones).
>
>Use of explicit time zone names other than UTC and GMT
>is depreciated, though. The better alternative is
>providing the offset from UTC being in effect at the
>given local time: +-HHMM (this is the offset you have
>to subtract from the given time in order to get UTC).
>"""
>again with the ParseDateTimeUTC factory function.
>
>See http://www.lemburg.com/files/python/mxDateTime.html
>for more details, download information, licensing, etc.
>
>
>Alex
>
>
>
>
Thanks for your response. Looks like I have to install a newer version of
Python as I'm running 1.5.1 and these extensions require at least 1.5.2. Don't
laugh, I'm only running this old version as it's very easy for our clients to
install since it comes precompiled.
Choppy
More information about the Python-list
mailing list