mktime() like function to produce GMT?

Mark Nottingham mnot at pobox.com
Mon May 3 06:16:00 EDT 1999


M.-A. Lemburg wrote [referring to mktime_tz()]:
> This doesn't always work. For one, time.timezone is set at
> module init time and does not necessarily apply to the UTC
> offset (depending on the platform). And second, mktime()
> with DST set to 0 will not return a UTC time value on all
> platforms: some implementations simply ignore the value
> and recalculate it depending on the local time broken
> down values.

This explanation fits well. After looking around the linux code (and being
somewhat shocked to learn that (according to them), it isn't POSIXly correct
to accept a TZ env variable), this appears to be the case (although my grasp
of linux internals is tenuous at best).

> I've had much trouble with this in mxDateTime, but finally found
> a rather well working trick that only relies on mktime()
> producing correct local time values.

Is it doable in Python-only (sorry, I've only taken a cursory glance over
the mxDateTime module; it looks very elegant and functional, but I'd like to
try and make the application use only standard library functions)?

Thanks,





More information about the Python-list mailing list