crontab: avoid next-time being minutes in the past.

windows-drag
John Benediktsson 2019-03-17 08:55:36 -07:00
parent 64d835e2bf
commit 112263ca3c
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,4 @@
USING: calendar crontab kernel tools.test ;
USING: calendar crontab kernel math.order tools.test ;
{
T{ timestamp
@ -20,3 +20,7 @@ USING: calendar crontab kernel tools.test ;
{ gmt-offset T{ duration { hour -8 } } }
} [ next-time-after ] keep
] unit-test
{ +lt+ } [
now "*/1 * * * *" parse-cronentry next-time <=>
] unit-test

View File

@ -55,6 +55,10 @@ CONSTANT: aliases H{
:: next-time-after ( cronentry timestamp -- )
timestamp second>> 0 > [
timestamp 0 >>second 1 minutes (time+) 2drop
] when
timestamp month>> :> month
cronentry months>> [ month >= ] find nip [
dup month = [ drop f ] [ timestamp month<< t ] if
@ -98,7 +102,7 @@ CONSTANT: aliases H{
] unless-zero ;
: next-time ( cronentry -- timestamp )
now 0 >>second [ next-time-after ] keep ;
now [ next-time-after ] keep ;
: parse-crontab ( -- entries )
lines harvest [ parse-cronentry ] map ;