Skip to content

Commit

Permalink
Merge pull request #1915 from flavio-fernandes/MagTag_Weather_Dayligh…
Browse files Browse the repository at this point in the history
…t_Adj

MagTag_Weather: sleep until 3:15 am to account for daylight adjustments
  • Loading branch information
TheKitty committed Nov 7, 2021
2 parents 66ce11e + 9dba620 commit 6b719f6
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 6b719f6

Please sign in to comment.