Fix sunrise wait windows on DST change days
daily_sunrise_video.sh and sunrise-audio-capture.sh added wall-clock seconds-since-midnight to a midnight epoch, which is 3600s off on the two days a year the clocks change. Resolve targets with date -d "today HH:MM:SS" instead. sunrise.py now builds local midnight with tz.localize(). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013wi3ZRpfenCe2TRwT4JFMG
This commit is contained in:
@@ -54,12 +54,13 @@ record_dur_sec=$SUNRISE_TARGET_SECS
|
||||
|
||||
echo "Audio window: ${half_pre}s before → ${half_post}s after sunrise (${record_dur_sec}s total)"
|
||||
|
||||
midnight=$(date -d "today 00:00:00" +%s)
|
||||
now_day_sec=$(( $(date +%s) - midnight ))
|
||||
wait_sec=$(( record_start_sec - now_day_sec ))
|
||||
# Resolve the wall-clock start via `date -d` (not midnight epoch + seconds):
|
||||
# on a DST day (23h/25h) those differ by 3600s.
|
||||
start_epoch=$(date -d "today $(printf '%02d:%02d:%02d' $((record_start_sec/3600)) $(((record_start_sec%3600)/60)) $((record_start_sec%60)))" +%s)
|
||||
wait_sec=$(( start_epoch - $(date +%s) ))
|
||||
|
||||
if [ "$wait_sec" -gt 0 ]; then
|
||||
echo "Waiting ${wait_sec}s until audio window ($(date -d "@$(( midnight + record_start_sec ))" '+%H:%M:%S'))..."
|
||||
echo "Waiting ${wait_sec}s until audio window ($(date -d "@$start_epoch" '+%H:%M:%S'))..."
|
||||
sleep "$wait_sec"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user