Schedule

cronic.Schedule$
See theSchedule companion class
object Schedule

Attributes

Companion:
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def parse(str: String): Schedule

Parse a string as a schedule.

Parse a string as a schedule.

The syntax is similar to that of systemd calendar specifications (man systemd.time).

E.g. Mon..Fri *-5/2-1 *:20,34:00

meaning:

  • from monday to friday (inclusive), and
  • any year, and
  • from may and every second month thereafter, and
  • any hour, and
  • minute 20 and 34, and
  • second 0

The schedule is parsed in three space-separated parts:

  1. a day-of-week filter
  2. a date filter
  3. a time filter

At least one of the of the parts must be specified, and they must be specified in order.

If a part is omitted, the following filters are assumed:

  • day-of-week part => any
  • date part => any
  • time part => 00:00:00

In other words, if the day-of-week part is omitted, any day of week is valid, if the date part is omitted then any date is valid, and if the time part is omitted then only midnight is valid.

In the date filter, if no year is specified, then any year matched. I.e. 10-2 is equivalent to *-10-2

In the time filter, if no second is specified, then second 0 is matched. I.e. 20:30 is equivalent to 20:30:00

A filter may be either *, or a disjunction of numbers or a range. * is the wildcard filter which matches anything. A disjunction is separated by , and any of the numbers or ranges must match for the schedule to happen. A range is given as start[..step][/step] (inclusive).

Examples

ExampleExpandedExplanation
Mon..FriMon..Fri *-*-* 00:00:00Every monday to friday at midnight
10-2Mon..Sun *-10-2 00:00:00Every 10th October to friday at midnight
2023-10-28Mon..Sun 2023-10-2 00:00:00On 2023-10-2 at midnight (this happens only once)
20:30Mon..Sun *-*-* 20:30:00Every day at 20:30
20:30:15Mon..Sun *-*-* 20:30:15Every day at 20:30:15
*-*-1/2Mon..Sun *-*-1/2 00:00:00On the first day of the month and every second day after (1st, 3rd, 5th etc...)
Tue *-*-1Tue *-*-1 00:00:00On the first day of the month, but only if it's a Tuesday
*:20,40Mon..Sun *-*-* *:20:40At twenty past and forty past every hour.

Specification in extended BNF

schedule       ::= [dayofweekspec] [datespec] [timespec]
dayofweekspec  ::= dayofweekrange{,dayofweekrange}
dayofweekrange ::= dayofweek[..dayofweek]
dayofweek      ::= 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat' | 'Sun'
datespec       ::= comps-comps | comps-comps-comps // either month-day or year-month-day
timespec       ::= comps:comps | comps:comps:comps // either hour:minute of hour:minute:second
comps          ::= comp{,comp}
comp           ::= '*' | filter
filter         ::= int[..int][/int]

Attributes

Throws:
IllegalArgumentException

if the specification was invalid

def tryParse(str: String): Option[Schedule]

Try to parse a string as a schedule, or return None if it was invalid.

Try to parse a string as a schedule, or return None if it was invalid.

Attributes

See also:

parse