time.daylight (Daylight Saving Time)
Matthew Dixon Cowles
matt at mondoinfo.com
Mon Nov 5 12:43:58 EST 2001
On Mon, 05 Nov 2001 13:59:39 +0100, Richard van de Stadt
<stadt at cs.utwente.nl> wrote:
>Hi,
Hi!
>I'm using time.tzname[time.daylight] to display the time zone. This worked
>fine as long a Daylight Saving Time (DST) was valid
[. . .]
>However, now that DST is over, time.daylight keeps on being 1 (on the
>5 systems located in different time zones that I've tried).
I think you're misinterpreting dime.daylight. At
http://www.python.org/doc/current/lib/module-time.html
it says:
daylight
Nonzero if a DST timezone is defined.
I think you want something more like:
>>> import time
>>> timeTuple=time.localtime(time.time())
>>> time.tzname[timeTuple[8]]
'CST'
You might want to check that daylight is nonzero first.
Regards,
Matt
More information about the Python-list
mailing list