New submission from CM:
On Windows (tested on XP), the datetime module (and, as reported online in [1],
time module) apparently gets the timezone only when a Python instance first
starts, but then never updates the timezone during the life of that Python
instance. So, if the user changes the system time zone while an application is
running, datetime still uses the time zone that the Python instance started
with, and so it is incorrect.
Example, Python 2.7.3:
First, the system time zone is set to Eastern U.S. and the system time shows
14:27.
>>> import datetime
>>> print datetime.datetime.now()
2013-04-03 14:27:43.124000
This is correct, and matches the system clock.
Now user changes time zone on Windows to GMT (and doesn't change the time).
Clock now shows the time as 18:29.
>>> print datetime.datetime.now()
2013-04-03 14:29:02.875000
^
This is incorrect and doesn't match the time shown on the system clock.
Note: if the user changes the system clock time and NOT the time zone, then
datetime updates the time fine.
This has been discussed in a Stack Overflow question, with a proposed
workaround[1], but it doesn't fix the fact that this makes datetime incorrect
for those that have processes that ought to continue across time zone changes
as the user moves.
[1]See accepted answer in particular here:
http://stackoverflow.com/questions/4360981/make-python-respond-to-windows-timezone-changes
----------
components: Library (Lib)
messages: 185943
nosy: cm
priority: normal
severity: normal
status: open
title: Datetime and time doesn't update timezone in a running Win app
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17627>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com