Skip to content

Commit

Permalink
crontab: support day=7 for Sunday, non-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Apr 6, 2023
1 parent 359eebb commit 7b83e4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions extra/crontab/crontab-tests.factor
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,14 @@ CONSTANT: start-timestamp T{ timestamp
"Sun, 24 Mar 2019 04:17:00 -0700"
}
} [ "5-20/3 4 * * *" next-few-times ] unit-test

! At 04:05 on Sunday.
{
{
"Sun, 24 Mar 2019 04:05:00 -0700"
"Sun, 31 Mar 2019 04:05:00 -0700"
"Sun, 7 Apr 2019 04:05:00 -0700"
"Sun, 14 Apr 2019 04:05:00 -0700"
"Sun, 21 Apr 2019 04:05:00 -0700"
}
} [ "5 4 * * 7" next-few-times ] unit-test
2 changes: 1 addition & 1 deletion extra/crontab/crontab.factor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ERROR: invalid-cronentry value ;
} cond ; inline recursive

: parse-day ( str -- n )
[ string>number ] [
[ string>number dup 7 = [ drop 0 ] when ] [
>lower $[ day-abbreviations3 [ >lower ] map ] index
] ?unless ;

Expand Down

0 comments on commit 7b83e4a

Please sign in to comment.