docs(scheduling): pin the pocketbase AND of day-of-month and day-of-week
tools/cron ANDs the two day fields where Vixie cron ORs them, so 0 0 1 * 1 means Monday the 1st, not the 1st or any Monday. State the deviation in the ScheduleCron comment and pin it with a test.
This commit is contained in:
1 parent
f46117b3e1
commit
dba811dfb2
2 files changed
+13
-3
No files matched your search
@@ -89,10 +89,12 @@ const (
|
||||
// (or after Start, if never run). The simplest recurring schedule.
|
||||
ScheduleInterval = "interval"
|
||||
|
||||
// ScheduleCron fires at the next moment matching a standard 5-field
|
||||
// cron expression (or one of the @ macros) after the last successful
|
||||
// ScheduleCron fires at the next moment matching a 5-field cron
|
||||
// expression (or one of the @ macros) after the last successful
|
||||
// run, computed in the zone of that run time. Expressions are parsed
|
||||
// with pocketbase tools/cron.
|
||||
// with pocketbase tools/cron, which ANDs day-of-month with day-of-week
|
||||
// instead of Vixie cron's OR: "0 0 1 * 1" means only Monday the 1st,
|
||||
// not "the 1st or any Monday".
|
||||
ScheduleCron = "cron"
|
||||
|
||||
// ScheduleOnce fires once at the configured At time. Subsequent
|
||||
|
||||
@@ -35,6 +35,14 @@ func TestScheduleCronNextRun(t *testing.T) {
|
||||
lastRun: zoned(2026, 8, 24, 12, 7, 0),
|
||||
want: zoned(2026, 8, 24, 12, 15, 0),
|
||||
},
|
||||
{
|
||||
// pins the pocketbase AND semantics: Vixie cron would give the
|
||||
// next Monday (2026-08-31); tools/cron gives Monday the 1st.
|
||||
name: "dual-restricted day-of-month and day-of-week AND, not Vixie OR",
|
||||
expr: "0 0 1 * 1",
|
||||
lastRun: zoned(2026, 8, 24, 12, 15, 30),
|
||||
want: zoned(2027, 2, 1, 0, 0, 0),
|
||||
},
|
||||
{
|
||||
name: "run exactly on a matching minute advances to the next one",
|
||||
expr: "0 * * * *",
|
||||
|
||||
Reference in new issue
Block a user