How do I find my local timezone?
Paul.Moore at atosorigin.com
Thu Oct 3 17:54:59 CEST 2002
I'm converting date/time values, and I have discovered a problem. I'm being passed a date string in either GMT or local time. That's fine, I create a tuple and use mktime(). However, in order to build the tuple, I may need to know my local timezone offset. Strangely, I can't find a way of getting it - neither the time or locale modules seem to provide this information.
I can *almost* get there, using time.strftime("%Z"), but (a) this feels like a hack, and (b) it gives the zone as a name, not as a numeric value on my box (Windows 2000). And %z which is mentioned in a footnote, returns the same as %Z for me, so that's no help, either...
Can anybody offer any help?
PS Hmm, just realised that if I compare gmtime() and localtime(), I can get what I want. It seems like a horrid hack, though... Is there anything cleaner?
More information about the Python-list