saturn-1.0.0.3: Handle POSIX cron schedules.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Saturn

Description

Saturn handles POSIX cron schedules, which are defined here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07.

A cron schedule is specified with five fields, each separated with at least one space. Each field can either be a wildcard (represented by an asterisk), or it can be one or more elements separated by commas. Each element can either be a number or a range, which is two numbers separated by a hyphen.

In order, the fields represent:

  1. Minute, between 0 and 59.
  2. Hour, between 0 and 23.
  3. Day, between 1 and 31.
  4. Month, between 1 and 12.
  5. Weekday, between 0 and 6 where 0 represents Sunday.

Here is a more graphical representation of the fields:

 +--------- Minute
 | +------- Hour
 | | +----- Day
 | | | +--- Month
 | | | | +- Weekday
 | | | | |
"* * * * *"

To get started, use fromText to parse a Schedule. Then use toText to render it again. To see if the Schedule matches a certain time, use isMatch. To get the next time that matches a schedule, use nextMatch.

>>> :set -XOverloadedStrings
>>> let Right schedule = fromText "* * * * *"
>>> toText schedule
"* * * * *"
>>> let utcTime = Data.Time.UTCTime (Data.Time.fromGregorian 1970 1 1) 0
>>> isMatch utcTime schedule
True
>>> nextMatch utcTime schedule
Just 1970-01-01 00:01:00 UTC
Synopsis

Types

data Schedule #

Instances

Instances details
Show Schedule 
Instance details

Defined in Saturn.Unstable.Type.Schedule

Eq Schedule 
Instance details

Defined in Saturn.Unstable.Type.Schedule

Parsing

Rendering

Matching