How do I get python to pick up the OS timezone change?
There is a function in the running python instance that I can call to say "Hey python, update what you know about the timezone information"? So let's say I open python and then change / etc / localtime. How can I get python to update to the new timezone? My goal is not to interfere with the TZ environment variable or / etc / localtime link directly, or use any OS specific commands. I would also like not to restart python. Is it possible?
+3
source to share
2 answers
The answer I was looking for was time.tzset () :
>>> time.tzname[time.daylight]
'CDT'
>>> #Use dpkg-reconfigure tzdata
...
>>> time.tzset()
>>> time.tzname[time.daylight]
'EDT'
>>>
+2
source to share