From c1b56860636fdbbad47b4f93fcac7de61d78ca7a Mon Sep 17 00:00:00 2001 From: akkuman Date: Fri, 31 Oct 2025 10:35:35 +0800 Subject: [PATCH] fix: ambiguity about time If the user defines the time zone of the container and uses cron at the same time, it will produce wrong results: cron.ParseStandard() defaults to using the local time zone to interpret cron expressions, but the time passed in Next is UTC, which will cause cron to change the original time zone to the time zone corresponding to the Next parameter, resulting in misunderstanding. --- pkg/core/timer.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/core/timer.go b/pkg/core/timer.go index d3bff6b..6ba3e7e 100644 --- a/pkg/core/timer.go +++ b/pkg/core/timer.go @@ -44,14 +44,14 @@ func Timer(opts TimerOptions) (<-chan Update, error) { // parse the options to determine our delays if opts.Cron != "" { // calculate delay until next cron moment as defined - now := time.Now().UTC() + now := time.Now() delay, err = waitForCron(opts.Cron, now) if err != nil { return nil, fmt.Errorf("invalid cron format '%s': %v", opts.Cron, err) } } else if opts.Begin != "" { // calculate delay based on begin time - now := time.Now().UTC() + now := time.Now() delay, err = waitForBeginTime(opts.Begin, now) if err != nil { return nil, fmt.Errorf("invalid begin option '%s': %v", opts.Begin, err) @@ -74,17 +74,17 @@ func Timer(opts TimerOptions) (<-chan Update, error) { // create our delay and timer loop and go for { - lastRun := time.Now().UTC() + lastRun := time.Now() if opts.Cron != "" { - now := time.Now().UTC() + now := time.Now() delay, _ = waitForCron(opts.Cron, now) } else { // calculate how long until the next run // just take our last start time, and add the frequency until it is past our // current time. We cannot just take the last time and add, // because it might have been during a backup run - now := time.Now().UTC() + now := time.Now() diff := int(now.Sub(lastRun).Minutes()) // make sure we at least wait one full frequency if diff == 0 {