diff --git a/lib/workers/repository/update/branch/schedule.spec.ts b/lib/workers/repository/update/branch/schedule.spec.ts index ca3338350ef31e..2f9ab17bb2d089 100644 --- a/lib/workers/repository/update/branch/schedule.spec.ts +++ b/lib/workers/repository/update/branch/schedule.spec.ts @@ -239,6 +239,30 @@ describe('workers/repository/update/branch/schedule', () => { expect(res).toBeFalse(); }); + describe('supports cron syntax on Sundays', () => { + beforeEach(() => { + mockDate.set('2023-01-08T10:50:00.000'); // Locally Sunday 8 January 2023 10:50am + }); + + it('approves if the weekday is *', () => { + config.schedule = ['* * * * *']; + const res = schedule.isScheduledNow(config); + expect(res).toBeTrue(); + }); + + it('approves if the weekday is 0', () => { + config.schedule = ['* * * * 0']; + const res = schedule.isScheduledNow(config); + expect(res).toBeTrue(); + }); + + it('rejects if the weekday is 1', () => { + config.schedule = ['* * * * 1']; + const res = schedule.isScheduledNow(config); + expect(res).toBeFalse(); + }); + }); + describe('supports timezone', () => { const cases: [string, string, string, boolean][] = [ ['after 4pm', 'Asia/Singapore', '2017-06-30T15:59:00.000+0800', false], diff --git a/lib/workers/repository/update/branch/schedule.ts b/lib/workers/repository/update/branch/schedule.ts index c4ace100418288..78bf22757189eb 100644 --- a/lib/workers/repository/update/branch/schedule.ts +++ b/lib/workers/repository/update/branch/schedule.ts @@ -98,7 +98,7 @@ function cronMatches(cron: string, now: DateTime): boolean { return false; } - if (parsedCron.weekDays.indexOf(now.weekday) === -1) { + if (!parsedCron.weekDays.includes(now.weekday % 7)) { // Weekdays mismatch return false; }