Skip to content

Commit cc9dd7c

Browse files
committed
fix: workdays and weekends according to crontab.guru
1 parent 9a5e889 commit cc9dd7c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ const dayParser = (pattern, string) => {
5151
if (daymatch) {
5252
const day = daymatch[0].trim();
5353
if (day === 'workdays') {
54-
pattern[5] = '1,2,3,4,5';
54+
pattern[5] = '1-5';
5555
} else if (day === 'weekends') {
56-
pattern[5] = '6,7';
56+
pattern[5] = '6,0';
5757
} else {
5858
const days = daymatch.map((i) =>
5959
['', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'].indexOf(i.trim())

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ test('every 15 minutes on dec 24', '0 */15 * 24 12 *');
2525
test('every 15 minutes on wednesdays', '0 */15 * * * 3');
2626
test('on saturdays at 0:10', '0 10 0 * * 6');
2727
test('every 1 hour on dec 24', '0 0 */1 24 12 *');
28-
test('every 3 hours on workdays', '0 0 */3 * * 1,2,3,4,5');
29-
test('every 12 hours on weekends', '0 0 */12 * * 6,7');
28+
test('every 3 hours on workdays', '0 0 */3 * * 1-5'); // => 1-5
29+
test('every 12 hours on weekends', '0 0 */12 * * 6,0'); // => should be 6,0
3030
test('every 20 seconds mondays tuesdays wednesdays', '*/20 * * * * 1,2,3');
3131
test('at 13:37 on fridays tuesdays and thursdays', '0 37 13 * * 2,4,5');
3232
test('at 9:00 on fri tue and mon', '0 0 9 * * 1,2,5');

0 commit comments

Comments
 (0)