Timezones

M.-A. Lemburg mal at lemburg.com
Thu May 27 04:37:14 EDT 1999


Greg McFarlane wrote:
> 
> I like the solutions Fred and Michael have proposed.  I don't think we
> need worry about a small amount of initial "memory leak", only about
> the continual loss due to repeated calls to putenv.
> 
> FYI, the reason this became a problem was a long running program
> (running in Sydney) that continuously received time-tagged data from a
> host in another timezone (Perth).  The data was in Perth time and the
> program needed to convert it GMT time.  The routine called was:
> 
> def convertLocalTimeToCalendarTime(timeTuple, timeZone):
>     saveTimeZone = os.environ['TZ']
>     os.environ['TZ'] = timeZone
>     calendarTime = time.mktime(timeTuple)
>     os.environ['TZ'] = saveTimeZone
>     return calendarTime
> 
> In the current configuration <timeZone> is 'Australia/West' and
> <saveTimeZone> is 'Australia/NSW'.
> 
> The solution is probably to get the mxDateTime package, but I haven't
> looked at that yet :)

It won't help you that much yet, except when you pass the data
in UTC which is what I would do to get "portable" date/time data.

Some future version will be able to convert from any TZ based
value to any other TZ timezone, but only if the TZ values correctly
state the daylight savings time and offsets for the given dates
(these setting do change quite often).

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   218 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/





More information about the Python-list mailing list