How to obtain GMT offset?

Bengt Richter bokr at oz.net
Tue Aug 16 21:37:26 CEST 2005


On Mon, 15 Aug 2005 20:57:16 -0700, Erik Max Francis <max at alcyone.com> wrote:

>new pip wrote:
>
>> I'm using Windows os. If the current system date time is '28 Jun 2001
>> 14:17:15 +0700', how can I obtain the value '+0700' using python?
>
>time.timezone gives you the timezone offset in minutes.
>
Hm, ...

>From help(time):

    Variables:

    timezone -- difference in seconds between UTC and local standard time
    altzone -- difference in  seconds between UTC and local DST time
    daylight -- whether local time should reflect DST
    tzname -- tuple of (standard time zone name, DST time zone name)

I learned something: there is an altzone variable. But is that a constant,
or is it zero during the standard-time part of the local year? (and since
we do not have module-level properties, what happens if you start python
during standard time and retrieve altzone after 1AM (or whenever the official
switchover happens)? Lack of property would seem to make constants for both
altzone and timezone safer. But then daylight should probably be an accessor
function, if it can't be a property ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list