Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability for user to change timezone #23

Open
joerick opened this issue Sep 21, 2016 · 3 comments
Open

Add ability for user to change timezone #23

joerick opened this issue Sep 21, 2016 · 3 comments

Comments

@joerick
Copy link
Member

joerick commented Sep 21, 2016

Should probably work similarly to the Wifi setup (and hostname #22 perhaps!), configuration on the SD from Tide.

@jessea3
Copy link

jessea3 commented Jan 17, 2017

As a workaround in the mean time, you can set the timezone within the particular app. You can store the timezone in any python-legal format in your app.settings file. The example shows a hardcoded one for the US/Eastern time zone.


import time
import os

# setup code here

#os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
os.environ['TZ'] = tingbot.app.settings['timezone']
time.tzset()

@bsheff
Copy link

bsheff commented Jan 23, 2017

your example:
#os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
os.environ['TZ'] = tingbot.app.settings['timezone']
time.tzset()
causes diagnostic: "line 68, in getitem
return self.dct[key]
keyerror: 'timezone'
"
on the other hand,

current_time = time.strftime("%A\n %Y-%m-%d %H:%M:%S %Z")

simulator produced: "Sunday 2017-01-22 22:55:10 Eastern Standard Time"
(too bad I couldnt Mark/Copy/paste)
actual Tingbot produced: Monday 2017 -01-23 03:28:31 UTC"
why not EST?
why cant I set the TIMEZONE in Tingbot?, (or better yet you could get it from local server on Bootup)

@jessea3
Copy link

jessea3 commented Jan 23, 2017

Did you set timezone in app.settings? I had placed the value there to generalize the code, but it could be hardcoded as well.

Python is returning a time relative to the machine you are running it on. In the case of the emulator, it is pulling the TZ from your computer, but on the Tingbot it is either undefined (which defaults to UTC) or set to UTC explicitly - I haven't dug deep enough to check.

If you want to do a quick check, try the following:

import time
import os

# setup code here
print time.strftime("%A\n %Y-%m-%d %H:%M:%S %Z")
os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
time.tzset()
print time.strftime("%A\n %Y-%m-%d %H:%M:%S %Z")

see the python docs for more information...

Ideally, the timezone value will be written to the SD card at the same time as the wireless information - I need to dig into the source and see what is being done....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants