Time zone changing while Win app is running

CM cmpython at gmail.com
Wed Apr 3 14:46:48 EDT 2013


On Apr 3, 7:37 am, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:
> On Tue, 02 Apr 2013 17:04:12 -0700, CM wrote:
> > To summarize the issue:  In an application, I have been using Python's
> > datetime module to get the current time.  But it seems that, at least
> > with Windows (XP), whatever time zone your computer is set to when you
> > start the application, that's what datetime will use--the time zone will
> > *not* be updated in the application when you update it manually with
> > Windows.  So, if you change the time zone (say, after traveling with
> > your laptop), all datetimes will be incorrect as compared to your system
> > clock.
>
> I am not the maintainer of the datetime module, but based purely on what
> you have said, I would consider that a bug. I suggest you report it as an
> issue on the Python bug tracker.

Thanks, I submitted an issue about it.  On 2.7.3, on Windows, it's
easy to demonstrate:

(Actual time = 2:40pm; tz = Eastern U.S.)

> import datetime
> print datetime.datetime.now()
2013-04-03 14:40:03.124000     <---- RIGHT

(Now change time zone to UTC, for example.  Now clock reads 6:41pm.)

> import datetime
> print datetime.datetime.now()
2013-04-03 14:41:13.124000     <---- WRONG
                   ^



More information about the Python-list mailing list