From d2df02b43205d78727273a8d78d52646b5e36e99 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Mon, 1 Sep 2025 09:26:30 -0600 Subject: [PATCH] update every hour at 59 minutes --- main.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index d2c4680..10306dc 100644 --- a/main.go +++ b/main.go @@ -69,8 +69,33 @@ func main() { for { // Main program loop refreshData() - log.Print("Sleeping for 6 hours...") - time.Sleep(time.Hour * 6) + + // Update at 59 minutes on the hour + + // Get current time + now := time.Now() + + // Calculate the next time at 59 minutes + next := time.Date( + now.Year(), + now.Month(), + now.Day(), + now.Hour(), + 59, + 0, + 0, + now.Location(), + ) + + // If we've already passed this hour's 59th minute, go to next hour + if !next.After(now) { + next = next.Add(time.Hour) + } + // Duration to sleep + duration := time.Until(next) + log.Printf("Sleeping until %v (%v)", next, duration) + + time.Sleep(duration) } }