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

Automatically get GMT offset from online API #3

Merged
merged 2 commits into from
Apr 9, 2022

Conversation

yoyoma2
Copy link
Contributor

@yoyoma2 yoyoma2 commented Nov 5, 2021

This change should close issue #1 since the timezone can be set automatically if configured correctly. If a tzdb.cfg file is created as follows (replace MY_API_KEY with your own free key):

http://api.timezonedb.com/v2.1/get-time-zone?key=MY_API_KEY&format=json&by=zone&zone=America/Toronto&fields=gmtOffset
autosave

The timezonedb.com API gives you the GMT offset for the zone you specify from this list. If the second line contains "autosave" then the time is saved and the app exits automatically.

Since not all time zones differ from GMT by full hours the display can now show minutes if needed.

This page mentioned WiiNetwork which led to BibleQuiz which is where html.[hc] and trace.[hc] come from (all credit to user wplaat) which allowed easily using the web-based timezone API.

Note: Without tzdb.cfg, behavior should be unchanged:

@yoyoma2
Copy link
Contributor Author

yoyoma2 commented Nov 7, 2021

Tested today after DST fallback and the Wii clock was adjusted correctly without any manual adjustments.

Note: A couple new global variables could probably be eliminated by doing all the timezone API stuff from the NTP thread itself but waiting to see if this feature is even wanted before cleaning that up.

@yoyoma2
Copy link
Contributor Author

yoyoma2 commented Apr 5, 2022

Tested today after DST spring forward and it wasn't getting the GMT offset automatically because timezonedb.com added a space in their reply to the query. Fixed it by adding a space to the pattern we are looking for in the reply.

The URL_TOKEN could be read from tzdb.cfg instead of being in the code so fixes like this wouldn't require recompiling.

Any chance this pull request can be merged? It adds the missing piece of automatic timezone handling to an already nice utility.

@ErikAndren ErikAndren merged commit b5ef038 into ErikAndren:master Apr 9, 2022
@yoyoma2 yoyoma2 mentioned this pull request Apr 9, 2022
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

Successfully merging this pull request may close these issues.

2 participants