cronexp.cronexp

This framework provides parser of cron expressions and evaluator of next date and time of triggering parsed cron expressions.

Cron expression consists of 6 required fields separated by white space

Supported fields:

Field Allowed values Special charachters

Seconds 0-59 , - * / Minutes 0-59 , - * / Hours 0-23 , - * / Day-of-month 1-31 , - * / ? Month 1-12 or JAN-DEC , - * / Day-of-week 1-7 or MON-SUN , - * / ?

Months names: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC Day-of-weeks names: MON,TUE,WED,THU,FRI,SAT,SUN

Charachters:

Asterisk (*): is used for specify all values (eg. 'every minute' in minute field)

Comma (,): is used for to separate items of a list (eg. using "MON,WED,FRI" in the 6th field (day of week) means Mondays, Wednesdays, Fridays)

Hyphen (-): is used for define ranges (eg. 10-30 in 1st field means every second between 10 and 30 inclusive)

Slash (/): is used for define step values, a/x = a, a+x, a+2x, a+3x, ... (eg. 2/4 in hours means list of 2,6,10,14,18,22) '*' mean minimal allowed value (eg. 0 for hours, 1 for months etc)

Question mark (?): is a synonym of '*' for day-of-week and day-of-month fields used to explicitly indicate that days are set with other field

More...

Members

Classes

CronException
class CronException

Cron exception

Functions

replaceNames
auto replaceNames(R expr, string names)

Replace names of dows and doms in expression

Structs

CronExpr
struct CronExpr

Struct containing parsed cron expression

Detailed Description

NOTES: - If both the 'Day-of-month' and 'Day-of-week' fields are restricted (aren't '*'), next correct time will be when both(!) fields match the conditions. For example: * * * 13 * FRI expression will be satisfied only on friday 13th. - Ranges can be overflowing, it means range 'NOV-FEB' (NOV > FEB) will expand in NOV,DEC,JAN,FEB

Meta

Authors

Maxim Tyapkin

License

This software is licensed under the terms of the BSD 3-clause license. The full terms of the license can be found in the LICENSE.md file.