Skip to content

MagTag_Weather: sleep until 3:15 am to account for daylight adjustments #1915

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MagTag_Weather/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def go_to_sleep(current_time):
# compute current time offset in seconds
hour, minutes, seconds = time.localtime(current_time)[3:6]
seconds_since_midnight = 60 * (hour * 60 + minutes) + seconds
# wake up 15 minutes after midnite
seconds_to_sleep = (24 * 60 * 60 - seconds_since_midnight) + 15 * 60
three_fifteen = (3 * 60 + 15) * 60
# wake up 15 minutes after 3am
seconds_to_sleep = (24 * 60 * 60 - seconds_since_midnight) + three_fifteen
print(
"Sleeping for {} hours, {} minutes".format(
seconds_to_sleep // 3600, (seconds_to_sleep // 60) % 60
Expand Down