Skip to content

Commit 6b719f6

Browse files
authored
Merge pull request #1915 from flavio-fernandes/MagTag_Weather_Daylight_Adj
MagTag_Weather: sleep until 3:15 am to account for daylight adjustments
2 parents 66ce11e + 9dba620 commit 6b719f6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

MagTag_Weather/code.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ def go_to_sleep(current_time):
155155
# compute current time offset in seconds
156156
hour, minutes, seconds = time.localtime(current_time)[3:6]
157157
seconds_since_midnight = 60 * (hour * 60 + minutes) + seconds
158-
# wake up 15 minutes after midnite
159-
seconds_to_sleep = (24 * 60 * 60 - seconds_since_midnight) + 15 * 60
158+
three_fifteen = (3 * 60 + 15) * 60
159+
# wake up 15 minutes after 3am
160+
seconds_to_sleep = (24 * 60 * 60 - seconds_since_midnight) + three_fifteen
160161
print(
161162
"Sleeping for {} hours, {} minutes".format(
162163
seconds_to_sleep // 3600, (seconds_to_sleep // 60) % 60

0 commit comments

Comments
 (0)