Under my debugger:
logging.info("TZ = %s -- It is now: %s", os.environ['TZ'], time.ctime())
TZ = UTC -- It is now: Mon Oct 17 12:10:44 2011
Under App Engine Launcher:
logging.info("TZ = %s -- It is now: %s", os.environ['TZ'], time.ctime())
TZ = UTC -- It is now: Mon Oct 17 17:09:24 2011
So what do I have setup wrong? This affects not just time.ctime(), but all the data dropped into the debug database. I'd like the debugger to run in the same "timeframe" as the app engine launcher because of timestamps in the database, and the debugger is slower than the launcher, so I don't want to use it all the time.
The issue is that the C runtime functions on Windows with Python 2.5 seem to cache the value of the TZ environment variable the first time either time or ctime is called. The following will display the time in local time and not in UTC:
import time, os
time.time()
os.environ['TZ'] = 'UTC'
print time.ctime()
Wing's debugger calls time() before running any AppEngine code so the initial value of TZ was captured. The workaround is to set TZ=UTC in the environment variables via the project properties dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With