refactor(cron): extract defaultTimezone constant

Per reviewer suggestion, replace hardcoded "UTC" with a package-level
constant for maintainability.
This commit is contained in:
王路路 2026-03-07 10:15:20 +08:00
parent 038a55e522
commit d784651ee5

View file

@ -15,6 +15,8 @@ import (
"github.com/sipeed/picoclaw/pkg/fileutil" "github.com/sipeed/picoclaw/pkg/fileutil"
) )
const defaultTimezone = "UTC"
type CronSchedule struct { type CronSchedule struct {
Kind string `json:"kind"` Kind string `json:"kind"`
AtMS *int64 `json:"atMs,omitempty"` AtMS *int64 `json:"atMs,omitempty"`
@ -273,7 +275,7 @@ func (cs *CronService) computeNextRun(schedule *CronSchedule, nowMS int64) *int6
tz = cs.defaultTZ tz = cs.defaultTZ
} }
if tz == "" { if tz == "" {
tz = "UTC" tz = defaultTimezone
} }
if loc, err := time.LoadLocation(tz); err == nil { if loc, err := time.LoadLocation(tz); err == nil {
now = now.In(loc) now = now.In(loc)