Bugs item #1198275, was opened at 2005-05-09 06:14 Message generated for change (Comment added) made by bcannon You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1198275&group_id=5470
Category: Extension Modules >Group: Python 2.3 >Status: Open >Resolution: None 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: Brett Cannon (bcannon) Date: 2005-05-11 13:35 Message: Logged In: YES user_id=357491 OK, fixed the version and reopened this. No, you don't need to poll, just call time.tzset() before you call time.localtime() or anything else that relies on the timezone. It isn't that expensive of a call. Post here if that fixes it or not. And in terms of inelegance, the only other solution is to implicitly call time.tzset() internally for all time functions. This is an issue imposed by the ISO C libraries. ---------------------------------------------------------------------- Comment By: David Lambert (jdalambert) Date: 2005-05-10 19: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 16: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 16: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 20: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 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com