crontab: avoid next-time being minutes in the past.
parent
64d835e2bf
commit
112263ca3c
|
@ -1,4 +1,4 @@
|
||||||
USING: calendar crontab kernel tools.test ;
|
USING: calendar crontab kernel math.order tools.test ;
|
||||||
|
|
||||||
{
|
{
|
||||||
T{ timestamp
|
T{ timestamp
|
||||||
|
@ -20,3 +20,7 @@ USING: calendar crontab kernel tools.test ;
|
||||||
{ gmt-offset T{ duration { hour -8 } } }
|
{ gmt-offset T{ duration { hour -8 } } }
|
||||||
} [ next-time-after ] keep
|
} [ next-time-after ] keep
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
{ +lt+ } [
|
||||||
|
now "*/1 * * * *" parse-cronentry next-time <=>
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -55,6 +55,10 @@ CONSTANT: aliases H{
|
||||||
|
|
||||||
:: next-time-after ( cronentry timestamp -- )
|
:: next-time-after ( cronentry timestamp -- )
|
||||||
|
|
||||||
|
timestamp second>> 0 > [
|
||||||
|
timestamp 0 >>second 1 minutes (time+) 2drop
|
||||||
|
] when
|
||||||
|
|
||||||
timestamp month>> :> month
|
timestamp month>> :> month
|
||||||
cronentry months>> [ month >= ] find nip [
|
cronentry months>> [ month >= ] find nip [
|
||||||
dup month = [ drop f ] [ timestamp month<< t ] if
|
dup month = [ drop f ] [ timestamp month<< t ] if
|
||||||
|
@ -98,7 +102,7 @@ CONSTANT: aliases H{
|
||||||
] unless-zero ;
|
] unless-zero ;
|
||||||
|
|
||||||
: next-time ( cronentry -- timestamp )
|
: next-time ( cronentry -- timestamp )
|
||||||
now 0 >>second [ next-time-after ] keep ;
|
now [ next-time-after ] keep ;
|
||||||
|
|
||||||
: parse-crontab ( -- entries )
|
: parse-crontab ( -- entries )
|
||||||
lines harvest [ parse-cronentry ] map ;
|
lines harvest [ parse-cronentry ] map ;
|
||||||
|
|
Loading…
Reference in New Issue