(next-time-after) ( cronentry timestamp -- )


Vocabulary
crontab.private

Inputs
cronentryan object
timestampan object


Outputs
None

Definition


:: (next-time-after) ( cronentry timestamp -- )
f timestamp month>> :> month cronentry months>>
[ month >= ] find nip dup month =
[ drop ] [
[ cronentry months>> first timestamp 1 +year drop ]
unless* timestamp 1 >>day 0 >>hour 0 >>minute month<<
drop t
] if
timestamp day-of-week :> weekday cronentry days-of-week>>
[ weekday >= ] find nip
[ cronentry days-of-week>> first 7 + ] unless* weekday -
:> days-to-weekday timestamp day>> :> day cronentry days>>
[ day >= ] find nip
[ cronentry days>> first timestamp days-in-month + ] unless*
day - :> days-to-day cronentry days-of-week>> length 7 =
cronentry days>> length 31 = 2array {
{ { f t } [ days-to-weekday ] }
{ { t f } [ days-to-day ] }
[ drop days-to-weekday days-to-day min ]
} case
[ timestamp 0 >>hour 0 >>minute swap +day 2drop t ]
unless-zero timestamp hour>> :> hour cronentry hours>>
[ hour >= ] find nip dup hour =
[ drop ] [
[ cronentry hours>> first timestamp 1 +day drop ]
unless* timestamp 0 >>minute hour<< drop t
] if timestamp minute>> :> minute cronentry minutes>>
[ minute >= ] find nip dup minute =
[ drop ] [
[ cronentry minutes>> first timestamp 1 +hour drop ]
unless* timestamp minute<< drop t
] if [ cronentry timestamp (next-time-after) ] when ;