Launched: Recurring dates with the Recurrence Rules pack

The Recurrence Rule pack enables you to build recurrence into your tables & docs to make event dates repeat according to a custom schedule.

Some examples of recurrence schedules:

  • Every day
  • Every week
  • Every month
  • Every weekday
  • Every 2 weeks on Tuesday
  • Every week on Monday, Wednesday
  • Every month on the 2nd last Friday for 7 times
  • Every 6 months

Recurrence Rules are strings formatted according to the RFC standard as documented here: 3.8.5.3. Recurrence Rule | iCalendar (RFC 5545) | RFC Specifications. “RRule” strings encode various options about the recurrence, such as the frequency (daily, monthly, …), the maximum count, the day-of-week to recur on, and many more.

These options are accepted as parameters to the CreateRRule() formula, which returns a RRule string. Alternatively, natural language processing can be used to parse free form text such as “Every month on the 2nd last Friday for 7 times” to create RRule strings, using the FromText() formula. See the note on natural language processing. RRule strings can also be modified once created to overwrite certain options, by calling the ModifyRRule() formula on an existing, valid RRule with some values for the parameters to overwrite (useful for creating generic RRule strings that are not tied to a specific point in time, that can then be modified on a case-by-case basis to add a start date, for example.)

Once a RRule string is created, occurrences (or instances) of the recurrence it defines can be retrieved using the All(), Between(), First(), After(), and Before() formulas. These formulas are all called with an existing, valid RRule string as their first parameter. Some common use cases include using the All() formula to retrieve all the occurrences of the RRule it is called on, the After() formula to retrieve the first occurrence after a specified date (useful to determine the “next” occurrence in an iterative fashion by advancing the specified date each time), while the Between() formula will return all the occurrences between the specified boundary dates. The All() and Between() formulas may operate on RRules yielding an unbounded number of occurrences. The number of results is capped with a limit that can be adjusted using the limit parameter of both formulas.

This pack is essentially an interface for the npm rrule package, itself a partial port of the rrule module from the python-dateutil library. See these projects and their documentations for further details. Note that there are a few minor differences in this pack, namely the formats of some of the input parameters being more flexible (e.g. “Monday”, “Mo”, “1” can all be used instead of only “MO”).

Note on natural language processing:

Parsing of free form text into RRule strings with FromText() and composing natural representations of RRule strings with ToText() is provided as a best-effort service. Many of the more complex options available when building a RRule string using the more robust CreateRRule() formula are not supported. The IsFullyConvertibleToText() formula can be called on a RRule string to determine whether all the options encoded wherein can be converted to natural language, i.e. whether a call to ToText() on that same RRule string would be lossless. These natural language formulas should be tested when used with more complex recurrence options to determine whether the result is acceptable, and assumed to be lossy.

11 Likes

Demo doc!

8 Likes

This is awesome! Thank you for sharing. I’m sure this will be extremely helpful to so many other Coda Makers.

5 Likes

@loucadufault,

this is a really solid piece of software engineering, resulting in an EXTREMELY useful Pack.

you have provided ALL the necessary functions, and then some!

i am especially pleased that you used a well documented ‘industry standard’ schema, rather than just building something ad hoc from scratch.

i am very grateful indeed.

well done, take a bow, and receive your deserved applause.

max

6 Likes

Congratulations on your launch, @loucadufault! What a useful pack!

Such a thorough documentation and set-up, absolutely great work!

4 Likes

Thank you for this wonderful and useful doc & pack! I have tried the pack and I was blown away, especially the free from text

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.