mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-18 04:47:28 +08:00
feat: implement cron expression support for scheduled tasks
This commit is contained in:
@@ -208,6 +208,15 @@ func (cs *CronService) computeNextRun(schedule *CronSchedule, nowMS int64) *int6
|
||||
return &next
|
||||
}
|
||||
|
||||
if schedule.Kind == "cron" && schedule.Expr != "" {
|
||||
parser := NewSimpleCronParser(schedule.Expr)
|
||||
next := parser.Next(time.UnixMilli(nowMS))
|
||||
if !next.IsZero() {
|
||||
ms := next.UnixMilli()
|
||||
return &ms
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user