[ python-Bugs-1198275 ] time module ignores timezone changes

SourceForge.net noreply at sourceforge.net
Wed May 11 04:33:40 CEST 2005


Bugs item #1198275, was opened at 2005-05-09 08:14
Message generated for change (Comment added) made by jdalambert
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1198275&group_id=5470

Category: Extension Modules
Group: Python 2.2.3
Status: Closed
Resolution: Wont Fix
Priority: 5
Submitted By: David Lambert (jdalambert)
Assigned to: Brett Cannon (bcannon)
Summary: time module ignores timezone changes

Initial Comment:
Running on Fedora Core 3 Linux

Consider the simple program

import time

while 1:
  print time.localtime()
  time.sleep(1)


The tuple printed by this program does not reflect any
change in the system timezone until the interpreter is
exited and restarted. Using reload(time) does not fix
the problem. Are there any workarounds?

----------------------------------------------------------------------

>Comment By: David Lambert (jdalambert)
Date: 2005-05-10 21:33

Message:
Logged In: YES 
user_id=845425

Ouch! I don't know how I got 2.2.3 on the bug report? My
version of Python is 2.3.4. Sorry for the confusion.:-( Let
me explain further. The problem is that I have a Python
script that is run as a daemon and uses localtime(). If
another program (outside of my control) changes the
timezone, the my daemon gets the local time according to the
original timezone. Do I have to periodically poll to see if
the timezone has changed? That seems somewhat inelegant.

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2005-05-10 18:10

Message:
Logged In: YES 
user_id=357491

Wait, I just noticed after I sent my follow-up that this bug
report is against Python 2.2.3 .  You won't find
time.tzset() that far back.  The issue is that you need to
use time.tzset() to reset the timezone for the C library
functions to use any change you have made since they cache
information internally.

I am closing this as "won't fix" since it has been resolved
in later versions and 2.2 is too old to bother backporting for.

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2005-05-10 18:07

Message:
Logged In: YES 
user_id=357491

David, how did you change the timezone?  And did you call
time.tzset()?  If you didn't call time.tzset(), that's the
problem.  If you did, then there is a bug.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-05-09 22:09

Message:
Logged In: YES 
user_id=80475

Brett, are you still in the time business?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1198275&group_id=5470


More information about the Python-bugs-list mailing list