Timezone

John W. Baxter jwbaxter at spamcop.com
Mon Jul 30 12:13:05 EDT 2001


In article <3B64B34C.6D8BEBE6 at tundraware.com>, Tim Daneliuk
<tundra at tundraware.com> wrote:

> Actually, this raises an interesting question, which perhaps the resident
> geniuses
> can 'splain to me.  Here in Chicago, we're currently 6 hourse or 21,600 sec
> *behind*
> UTC.  Why does time.timezone return 21600, not -21600?  It seems that for
> arithmetic reasons, you'd want to know both the magnitude and direction of
> this vector...
> 
> Inquiring minds wanna know ;)

Actually, you're currently at 5 hours from GMT...you're 6 during the
winter.  time.timezone appears to be returning the zone without regard
to silly adjustments like daylight time.  As per the library reference:
"The offset of the local (non-DST) timezone, in seconds west of UTC
(i.e. negative in most of Western Europe, positive in the US, zero in
the UK)."  I think you need to look at the "dst flag" in
time.localtime()'s result to learn the current status.  [It looks as if
the C and Unix folks have forgotten about "British Double Summer Time"
from WW-II, although Mac OS 9 and below record a DST delta rather than
a flag, which could have handled that.]

If you were 6 hours the other way from GMT, you would get -21600. 
Basically, one needs a convention.  (Naturally, given two choices of
convention here, the industry uses both in different places.)

You either get the number of seconds to add to GMT to give local time,
or the number of seconds to add to local time to give GMT.  

(There are also sub-conventions...it may be given in hours and minutes,
instead, as it is in email headers...yours for that purpose is -0500
currently.)

Is it any wonder that thing happen like the loss of an early moon
unmanned visitor because the ground thought a negative yaw meant "go
right" while the craft thought it meant "go left?"  [Or vice versa.]

  --John



More information about the Python-list mailing list