Timezone

Richard van de Stadt stadt at cs.utwente.nl
Mon Jul 30 11:45:34 EDT 2001


Tim Daneliuk wrote:
> 
> Richard van de Stadt wrote:
> >
> > I run stuff on systems in various timezones.
> > I need to display when certain files have been updated.
> > ctime (time()) shows the current date and time, but without the timezone
> > that you get to see e.g. by Unix' date command.
> >
> > Is there a (Python) way to find out the timezone?
> >
> > Richard.
> 
> import time
> 
> time.tzname
> 
> ...will return a tuple containing the strings which name the timezone
[...]

Thanks for the hint. That's a start.

Now, what else does time have? (toggle, toggle. Hey, there's no time.py!?)

>>> dir(time)
['__doc__', '__file__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'strptime', 'time', 'timezone', 'tzname']
>>> time.daylight
1

There we are:

Now, assuming that the value of daylight will become 0 when daylight saving
time is over, this is what I needed: time.tzname[time.daylight]

Richard.



More information about the Python-list mailing list