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