Every Calendar +1 Custom Expressions

Custom expressions allow you to write complex repeating patterns. These are loosely modelled on crontab syntax so if you're familiar with it then this should not be too different. Please note that ALL expression components must match for a date to be considered. Here are some examples, the syntax is explained below:

Simple examples:
 DoM  MoY  DoW  WsE
  *    *    1    *    Every Sunday
  1   */2   *    *    First day every 2nd month
  1   3/2   *    *    First day every 2nd month when month is March
 -1    *    *    *    Last day of the month
  *    *    6   1,-1  First after epoch and last Friday before 1 year repeat
  *    *    1   1/3   Every 3rd Sunday (1st in group)
  *    *    4   2/4   Every 4th Wednesday (2nd in group)
  *    *   1/3   *    The 3rd Sunday of every month
  *    *   2/-1  *    Last Monday every month
  *   */3  1/-2  *    2nd last Sunday every 3rd month
 -2   */6  4,5/5 *    2nd last day of every 6 month where it is the 5th Wed|Thur of the month

Some more complicated expression examples:
 DoM    MoY            DoW      WoY
 *      *              2/1,-1   *         First and last Monday of every month
 10-20  *              2        *         Mondays between 10th and 20th
 *      2,3,4,5,12     2/-1     *         Last Monday of Feb|Mar|Apr|May|Dec
 5-25   3,4,5,9,10,11  6/1,4    *         1st|4th Friday of the month where day is 5th-25th in Autumn/Spring
 *      */3            1/-1--3  *         Last, 2nd and 3rd Last Sundays of every 3rd month
 2-8    2,5,9,10/2,5   3,4/1,2  *         1st/2nd Tue|Wed where is 2nd-8th in Feb|May|Sep|Oct and is 2nd or 5th Month cycle since start
 *      1,2,12         2,3      1,2/5,7   Mon|Tue of 1st|2nd weeks in a 5|7 week rolling cycle since epoch in Summer month

Day of Month

The DoM values can take one of 5 forms and represent the numbered day of the month:

  1. * - Any day can be a repeat
  2. A positive number - Only the Xth day can be a repeat
  3. A negative number - Only the last Xth day can be a repeat
  4. Comma separated - Only the listed days (postive and negative) can be a repeat
  5. X-Y - All days from X to Y (inclusive) can be a repeat

Month of Year

The MoY values have two sub-parts which both have various forms which combine to represent a calendar month (Jan-Dec):

  1. The first part is the month numeric index match where 1 = January and 12 = December (REQUIRED):
    1. * - Any month can have repeats
    2. Positive number - Only the specific month can have repeats
    3. Comma separated - Only the specified months can have repeats
  2. The second part is optional and if given should be separated from the first part by a /. The second part represents the cycle period(s) for rolling months (e.g. every 3rd month):
    1. Positive number - Every Xth month (e.g. */2 is every 2nd month)
    2. Comma separated - Every Xth, Yth, Zth, etc.. month (e.g. */2,3 is every 2nd and every 3rd month)

The cycle periods start from the event epoch (i.e. the scheduled start date of the event); if multiple cycles are specified they repeat independently of each other.

Day of Week

The DoW values represent the specific days of a week (i.e. 1 = Sunday and 7 = Saturday) which an event can run on. Once again divided into two sub-parts:

  1. The first part is the day numeric index (REQUIRED):
    1. * - Any day of the week
    2. Positive number - Only the specific day of the week
    3. Comma separated - Only the specified days of the week
  2. The second part is optional and if given should be separated from the first part by a /. The second part represents the Xth time this day has occured in a month:
    1. Positive number - Only the Xth occurance of the specified days (e.g. 1/1 is first Sunday, 6/4 is fourth Friday)
    2. Negative number - Only the last Xth occurance of the specified days (e.g. 1/-1 is last Sunday)
    3. Comma separated - All of the Xth, Yth, Zth, etc... occurances (e.g. 1/1,-1 is first and last Sunday)
    4. X-Z - Short hand for X,Y,Z but otherwise as above.

Weeks since Epoch

The epoch is the start date of the event.

The WsE value counts the number of weeks since the original start date so that you can repeat on a weekly basis.

There are two forms for WsE:

  1. * - Any week since epoch
  2. Comma separated - Repeat at the specified weeks in an annual cycle (e.g. 13,26 repeat every 13th and 26th week)
  3. X/Y - Some week since epoch should be applied:
    1. The first part (X) represents the weeks of the period to repeat on (e.g. 1,2/3 means the 1st and 2nd weeks in a 3 week cycle)
    2. The second part (Y) represents the cycle period(s) to repeat over (e.g. 2/4,5 means the 2nd week of both a 4 and a 5 week cycle)

The WsE values are the most complex to understand but the intention is to allow X weekly repeating events (e.g. fort-nightly Saturdays: * * 7 1/2).