Wraps day-of-the-month values.
Represents the individual fields on a Spec, constrained to specific field types based on the position in said Spec.
Wraps hour values.
Raised at runtime when constructing invalid Spec instances.
Wraps minute values.
Sum type representing the months of the year.
Represents a crontab entry's time and date specification.
Sum type representing the days of the week.
Crontab
Provides utilities for working with crontab time and date specifications.
Overview
The main class to use is Spec. It can be used to instantiate valid crontab specs and to generate and match upcoming datetimes that match it. Its companion object provides a method that can be used to parse crontab specifications.
Parsing
On success, a
Right
value containing the Spec is returned:On failure, a
Left
value containing a parse error is returned:Spec usage
Specs can be used to generate upcoming dates that match from a given start time (defaults to the current time + 1 minute):
They can also be used to check if specific dates match:
Warning
It is possible for certain specs to cause
dateTimes
to loop infinitely (i.e. when no upcoming date times match the spec) so handle user-input specs with extra care.