IRecur class

IRecur(optionsopt)

new IRecur(optionsopt)

The IRecur object (part of ExICalendar/JS) defines recurrence rules (RRULE) in accordance with the Internet Calendaring and Scheduling Core Object Specification (RFC 5545). It allows you to parse RRULE expressions and generate the corresponding occurrences.

For example, the RRULE expression "FREQ=DAILY;INTERVAL=2" defines a recurrence that repeats every two days. Calling IRecur.Parse("FREQ=DAILY;INTERVAL=2").all() returns all occurrences generated by this rule.

The IRecur.Parse(expression) method parses the specified recurrence rule string and returns an object of type IRecur. Once parsed, you can use the IRecur.all(options) method to retrieve either all occurrences or a limited set of occurrences, depending on the provided options (such as date range or maximum count).

The IRecur object supports common RRULE components such as FREQ, INTERVAL, COUNT, UNTIL, BYDAY, BYMONTH, BYMONTHDAY, and others, allowing you to define complex recurrence patterns like weekly events on specific days, monthly events on a certain weekday, or yearly events on a specific date.

Parameters:
Name Type Attributes Description
options IRecurOptions <optional>
Specifies the options to create the parsing object, as an object of exontrol.ICalendar.IRecurOptions type.
Requires:
  • module:exontrol.commmon.min.js
Example
The following samples are equivalent, as they both parse the same RRULE expression "FREQ=WEEKLY;BYDAY=MO;INTERVAL=2" to create an IRecur object that defines a recurrence rule for an event that occurs every two weeks on Monday:

 var oRecur = exontrol.ICalendar.IRecur.Parse("FREQ=WEEKLY;BYDAY=MO;INTERVAL=2");

and

 var oRecur = new exontrol.ICalendar.IRecur();
 oRecur.parse("FREQ=WEEKLY;BYDAY=MO;INTERVAL=2");

Once you have the IRecur object, you can call the all() method to get the occurrences generated by the rule. For example, to get the first 10 occurrences of the rule, you can use the following code:

 oRecur.all({count: 10, asDate: true}).forEach(function(element)
 {
   console.log(element);
 });

Requires

  • module:exontrol.commmon.min.js

Members

(static, readonly) type :string

The type field holds the full name of the object, since constructor.name can differ in minimized or obfuscated code. This field is never altered by the control itself, so it can be reliably used to verify the object's type. It is particularly useful when multiple versions of a control exist or when you need to check the type without depending on constructor.name, which may be inconsistent in some scenarios, such as minified code. The IRecur.type member always returns "IRecur"
Type:
  • string
Since:
  • 1.8
Example
console.log(exontrol.IRecur.type); // logs "IRecur"

(static, readonly) version :string

The version field defines the version of the control. Each release of the control has a different version number, so you can use this field to check the control's version and ensure that it supports the features you want to use. The version field is especially useful when you have multiple versions of the control, or when you want to check the version of the control without relying on other properties or methods that may differ between versions. The current version is 3.2
Type:
  • string
Example
console.log(exontrol.IRecur.version); // displays the version of the control, for instance "3.2"

(static) count :number

The count field defines the number of recurrences to get if no UNTIL or COUNT part rule. The default value is 256, which means that if the recurrence rule does not specify an UNTIL or COUNT part, the IRecur.all() method will return up to 256 occurrences. This field can be adjusted based on your needs, but it is important to note that setting it too high may lead to performance issues if the recurrence rule generates a large number of occurrences. The count field serves as a safeguard to prevent infinite loops or excessive memory usage when dealing with recurrence rules that could potentially generate an unbounded number of occurrences.
Type:
  • number
Example
10 {number}, limits the number of occurrences to get to 10, since no UNTIL or COUNT part rule is specified in the RRULE expression
count

Methods

all(optionsopt) → {object}

The all() method retrieves all recurrences or only a subset of them, depending on the specified options. It generates occurrences based on the FREQ, INTERVAL, BYDAY, BYMONTHDAY, BYYEARDAY, BYWEEKNO, and BYMONTH rule components, as well as the values provided through the options parameter.

The method returns undefined if the rule expression is invalid. Otherwise, it returns an object of type exontrol.Arr([dateTimeN]), where each dateTimeN represents the value returned by JavaScript's Date.getTime() method (the number of milliseconds since January 1, 1970, 00:00:00 UTC).

  • If options.asDate is set to true (since 5.2), the method returns an exontrol.Arr({Date}) object, where each item is a JavaScript Date object
  • If options.asArray is set to true (since 5.2), the method returns a standard JavaScript array instead of exontrol.Arr, containing either date-time numbers or Date objects (when options.asDate is also true)

The valid() method checks whether the current recurrence-expression is valid. If the expression is invalid, the all() method returns undefined. Otherwise, it returns the recurrences based on the rules and options.

Parameters:
Name Type Attributes Description
options object <optional>
Defines the options to collect recurrences, as an object of {start,count,until,filter} type. If options is missing the method gets all recurrences.
Properties
Name Type Description
start number | string | Date Specifies the date the method starts collecting recurrences from. If missing the DTSTART rule or current date and time is used instead. If start option and DTSTART rule are present, the method collects recurrences from max(start, DTSTART).
until number | string | Date Specifies the date the method ends collecting recurrences to. If missing the UNTIL rule is used instead. If until option and UNTIL rule are present, the method collects recurrences until min(until, UNTIL).
count number Specifies the number of recurrences to return (overrides the COUNT rule). If missing, the COUNT rule is used instead.
filter callback Specifies a function of callback(dateTimeN) {number} type that filters the date-time within the result. The dateTimeN parameter indicates the result of getTime() method of a Date object (An integer value representing the number of milliseconds since January 1, 1970, 00:00:00 UTC). For instance: function(dateTime) { return dateTime - dateTime % exontrol.msday; } excludes the time from the each date-time of the result.
asDate boolean Specifies whether the result should contain Date objects instead of date-time numbers. If the asDate option is true, the result is an object of exontrol.Arr({Date}) type, where each Date is an object of Date type (@since 5.2).
asArray boolean Specifies whether the result should be an array instead of an exontrol.Arr object. If the asDate option is true, the result is an array of Date objects (@since 5.2).
Returns:
Returns one of the following:
  • undefined, if the rules-expression is not valid
  • an object of exontrol.Arr([dateTimeN]) type, where dateTimeN is the result of Date's getTime() method (An integer value representing the number of milliseconds since January 1, 1970, 00:00:00 UTC)
  • (options.asArray) an array or of [dateTimeN] type, where dateTimeN is the result of Date's getTime() method (An integer value representing the number of milliseconds since January 1, 1970, 00:00:00 UTC) (@since 5.2)
  • (options.asDate) an object of exontrol.Arr({Date}) type, where each Date is an object of Date type (@since 5.2)
  • (options.asDate and options.asArray) an array of {Date} type, where each Date is an object of Date type (@since 5.2)
Type
object
Example
all(), {object} returns all recurrences, as an object of exontrol.Arr([dateTimeN]) type
all({filter: function(dateTime) { return dateTime - dateTime % exontrol.msday; }}), {object} returns all recurrences, as an object of exontrol.Arr([dateN]) type (excludes the time)
all({start: 2001}), {object} returns all recurrences after Jan 1st, 2001, as an object of exontrol.Arr([dateTimeN]) type
all({until: "#2/15/2002#"}), {object} returns all recurrences before Feb 15st, 2002, as an object of exontrol.Arr([dateTimeN]) type
all

error() → {string}

The error() method describes the parsing error. The method returns an empty string if there is no parsing error, or a string that describes the parsing error if there is a parsing error. The valid() method can be used to check whether there is a parsing error or not. The get() method can be used to get the value of a rule, if there is no parsing error. The has() method can be used to check whether a rule exists, if there is no parsing error.

The parsing error shows as one of the following:

  • Error: Empty or Invalid recurrence
  • Error: The FREQ rule is missing or invalid
  • ...
  • Error: The UNTIL rule is invalid
  • Error: Unknown RRULE property '...'
Returns:
Returns the description of the parsing error.
Type
string

get(rule) → {any}

The get() method requests the value of specified rule. The method returns undefined if there is a parsing error or if the rule is not found, or returns the value of the rule if there is no parsing error and the rule is found. The valid() method can be used to check whether there is a parsing error or not. The has() method can be used to check whether a rule exists, if there is no parsing error.
Parameters:
Name Type Description
rule string Indicates the name of the rule to request as one of the following (case insensitive):
  • "FREQ", identifies the type of recurrence rule. This rule part MUST be specified in the recurrence rule.
  • "DTSTART", specifies the date the recurrence starts from, in YYYYMMDD[THHNNSS[Z]] format.
  • "INTERVAL", represents a positive integer representing at which intervals the recurrence rule repeats.
  • "COUNT", defines the number of occurrences at which to range-bound the recurrence.
  • "WKST", specifies the day on which the workweek starts.
  • "UNTIL", defines a DATE or DATE-TIME value that bounds the recurrence rule in an inclusive manner.
  • "BYWEEKNO", specifies a COMMA-separated list of ordinals specifying weeks of the year.
  • "BYDAY", specifies a COMMA-separated list of days of the week.
  • "BYMONTHDAY", specifies a COMMA-separated list of days of the month.
  • "BYYEARDAY", specifies a COMMA-separated list of days of the year.
  • "BYSETPOS", specifies a COMMA-separated list of values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule.
  • "BYMONTH", specifies a COMMA-separated list of months of the year.
  • "BYHOUR", specifies a COMMA-separated list of hours of the day.
  • "BYMINUTE", specifies a COMMA-separated list of minutes within an hour.
  • "BYSECOND", specifies a COMMA-separated list of seconds within a minute.
Returns:
Returns undefined if no rule is found, or the value of the rule, as explained:
  • "FREQ" {string}, "SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY", "MONTHLY", "YEARLY"
  • "DTSTART" {Date}, an object of Date type
  • "INTERVAL" {number}, a positive integer
  • "COUNT" {number}, an integer
  • "WKST" {exontrol.WeekDayEnum}, any integer between 0 to 6
  • "UNTIL" {Date}, an object of Date type
  • "BYWEEKNO" {number[]}, stores an array of [number] type. Valid values are 1 to 53 or -53 to -1.
  • "BYDAY" {map}, gets undefined (missing or invalid values for "BYDAY" rule), or a map of [weekday => [ordwk]] type, where weekday is of exontrol.WeekDayEnum type and ordwk is an integer between -53 and 53
  • "BYMONTHDAY" {number[]}, stores an array of [number] type. Valid values are 1 to 31 or -31 to -1.
  • "BYYEARDAY" {number[]}, stores an array of [number] type. Valid values are 1 to 366 or -366 to -1.
  • "BYSETPOS" {number[]}, stores an array of [number] type. Valid values are 1 to 366 or -366 to -1.
  • "BYMONTH" {number[]}, stores an array of [number] type. Valid values are 1 to 12.
  • "BYHOUR" {number[]}, stores an array of [number] type. Valid values are 0 to 23.
  • "BYMINUTE" {number[]}, stores an array of [number] type. Valid values are 0 to 59.
  • "BYSECOND" {number[]}, stores an array of [number] type. Valid values are 0 to 60.
Type
any

has(rule) → {boolean}

The has() method checks whether the specified rule exists. The method returns a truthy value if the rule exists, or returns undefined if the rule does not exist. The valid() method can be used to check whether there is a parsing error or not. The get() method can be used to get the value of a rule, if there is no parsing error and the rule exists.
Parameters:
Name Type Description
rule string Indicates the name of the rule to request (case insensitive). Valid values are:
  • "FREQ", identifies the type of recurrence rule. This rule part MUST be specified in the recurrence rule.
  • "DTSTART", specifies the date the recurrence starts from, in YYYYMMDD[THHNNSS[Z]] format.
  • "INTERVAL", represents a positive integer representing at which intervals the recurrence rule repeats.
  • "COUNT", defines the number of occurrences at which to range-bound the recurrence.
  • "WKST", specifies the day on which the workweek starts.
  • "UNTIL", defines a DATE or DATE-TIME value that bounds the recurrence rule in an inclusive manner.
  • "BYWEEKNO", specifies a COMMA-separated list of ordinals specifying weeks of the year.
  • "BYDAY", specifies a COMMA-separated list of days of the week.
  • "BYMONTHDAY", specifies a COMMA-separated list of days of the month.
  • "BYYEARDAY", specifies a COMMA-separated list of days of the year.
  • "BYSETPOS", specifies a COMMA-separated list of values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule.
  • "BYMONTH", specifies a COMMA-separated list of months of the year.
  • "BYHOUR", specifies a COMMA-separated list of hours of the day.
  • "BYMINUTE", specifies a COMMA-separated list of minutes within an hour.
  • "BYSECOND", specifies a COMMA-separated list of seconds within a minute.
Returns:
Returns a truthy value that specifies whether the rule exists
Type
boolean

parse(expression) → {IRecur}

The parse() method parses the giving expression and sets the rules and values of the IRecur object accordingly. The valid() method can be called after this method to check if the parsing is successful and the rules are valid. The error() method can also be called to get the parsing error details if the parsing is not successful.
Parameters:
Name Type Description
expression string Indicates the expression as a string of "rule=value;..." RRULE format, as defined in RFC 5545. The rules can be in any order, separated by ; (semi-colon) character and could be as follows:
  • FREQ, {string} The FREQ rule part identifies the type of recurrence rule. This rule part MUST be specified in the recurrence rule.
    The valid values are "SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY", "MONTHLY" and "YEARLY", as explained:
    • SECONDLY, to specify repeating events based on an interval of a second or more
    • MINUTELY, to specify repeating events based on an interval of a minute or more
    • HOURLY, to specify repeating events based on an interval of an hour or more
    • DAILY, to specify repeating events based on an interval of a day or more
    • WEEKLY, to specify repeating events based on an interval of a week or more
    • MONTHLY, to specify repeating events based on an interval of a month or more
    • YEARLY, to specify repeating events based on an interval of a year or more

    For example, "FREQ=DAILY;" indicates a daily recurrence rule.

  • DTSTART, {Date} The DTSTART rule specifies the date the recurrence starts from, in YYYYMMDD[THHNNSS[Z]] format. If missing the current date and time is used.
    The format supports:
    • DATE format, as YYYYMMDD (for example, 20220101 indicates January 1st, 2022)
    • DATE-TIME format, as YYYYMMDDTHHNNSS (for example, 20220101T090000 indicates January 1st, 2022, at 09:00 AM local time)
    • DATE-TIME in UTC format, as YYYYMMDDTHHNNSSZ (for example, 20220101T090000Z indicates January 1st, 2022, at 09:00 AM UTC)
    where:
    • YYYY indicates the year
    • MM indicates the month (01 = January, 02 = February, ..., 12 = December)
    • DD indicates the day of the month (01 through 31)
    • T character is used to separate the date and time portions of the value
    • HH indicates the hour (00 through 23)
    • NN indicates the minute (00 through 59)
    • SS indicates the second (00 through 60)
    • Z character indicates that the time is in UTC format.

    For example, "FREQ=DAILY;DTSTART=20220101T090000Z;" indicates a daily recurrence rule starting from January 1st, 2022, at 09:00 AM UTC.

  • INTERVAL {number} The INTERVAL rule part contains a positive integer representing at which intervals the recurrence rule repeats.
    The default value is "1", meaning:
    • every 1 second for a SECONDLY rule
    • every 1 minute for a MINUTELY rule
    • every 1 hour for an HOURLY rule
    • every 1 day for a DAILY rule
    • every 1 week for a WEEKLY rule
    • every 1 month for a MONTHLY rule
    • every 1 year for a YEARLY rule
    For example, "FREQ=DAILY;INTERVAL=8" indicates a recurrence rule every eight days
  • COUNT, {number} The COUNT rule part defines the number of occurrences at which to range-bound the recurrence. The DTSTART property value always counts as the first occurrence. The COUNT rule part is a positive integer.
    For example, "FREQ=DAILY;COUNT=10" indicates a recurrence rule for 10 times
  • WKST, {string} The WKST rule part specifies the day on which the workweek starts. The default value is MO. The WKST rule part is significant when a WEEKLY "RRULE" has an interval greater than 1, and a BYDAY rule part is specified. This is also significant when in a YEARLY "RRULE" when a BYWEEKNO rule part is specified.
    Valid values are:
    • MO, for Monday
    • TU, for Tuesday
    • WE, for Wednesday
    • TH, for Thursday
    • FR, for Friday
    • SA, for Saturday
    • SU, for Sunday

    For example, "FREQ=WEEKLY;WKST=SU" indicates a weekly recurrence rule where the week starts on Sunday

  • UNTIL, {Date} The UNTIL rule part defines a DATE or DATE-TIME value that bounds the recurrence rule in an inclusive manner. If the value specified by UNTIL is synchronized with the specified recurrence, this DATE or DATE-TIME becomes the last instance of the recurrence.
    The format of UNTIL is YYYYMMDD[THHNNSS[Z]], supporting:
    • DATE format, as YYYYMMDD (for example, 20220101 indicates January 1st, 2022)
    • DATE-TIME format, as YYYYMMDDTHHNNSS (for example, 20220101T090000 indicates January 1st, 2022, at 09:00 AM local time)
    • DATE-TIME in UTC format, as YYYYMMDDTHHNNSSZ (for example, 20220101T090000Z indicates January 1st, 2022, at 09:00 AM UTC)
    where:
    • YYYY indicates the year
    • MM indicates the month (01 = January, 02 = February, ..., 12 = December)
    • DD indicates the day of the month (01 through 31)
    • T character is used to separate the date and time portions of the value
    • HH indicates the hour (00 through 23)
    • NN indicates the minute (00 through 59)
    • SS indicates the second (00 through 60)
    • Z character indicates that the time is in UTC format.

    For example, "FREQ=DAILY;UNTIL=20220110T090000Z" indicates a daily recurrence rule until January 10th, 2022, at 09:00 AM UTC.

  • BYWEEKNO, {string} The BYWEEKNO rule part specifies a COMMA-separated list of ordinals specifying weeks of the year. Valid values are 1 to 53 or -53 to -1. The week numbering follows the ISO 8601 standard, where the first week of the year is the week that contains the first Thursday of the year. For example, week number 1 is the week with the first Thursday in January. Week number 52 is the week with the last Thursday in December. Week number 53 is only used in years where January 1st is a Thursday or a leap year where January 1st is a Wednesday. The BYWEEKNO rule part MUST NOT be specified when the FREQ rule part is set to DAILY, WEEKLY, or MONTHLY.
    For example, "FREQ=YEARLY;BYWEEKNO=20,30" indicates a yearly recurrence rule on the 20th and 30th weeks of the year
  • BYDAY, {string} The BYDAY rule part specifies a COMMA-separated list of days of the week. Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific day within the MONTHLY or YEARLY "RRULE". For example, within a MONTHLY rule, +1MO indicates the first Monday of the month, whereas -1MO indicates the last Monday of the month. Within a YEARLY rule, +3TU indicates the third Tuesday of the year. Valid values for n are 1 to 5 or -5 to -1. The BYDAY rule part MUST NOT be specified when the FREQ rule part is set to DAILY.
    Valid values are:
    • MO, for Monday
    • TU, for Tuesday
    • WE, for Wednesday
    • TH, for Thursday
    • FR, for Friday
    • SA, for Saturday
    • SU, for Sunday

    For example, "FREQ=WEEKLY;BYDAY=MO,WE,FR" indicates a weekly recurrence rule on Monday, Wednesday and Friday

  • BYMONTHDAY, {string} The BYMONTHDAY rule part specifies a COMMA-separated list of days of the month. Valid values are 1 to 31 or -31 to -1. For example, -10 represents the tenth to the last day of the month. The BYMONTHDAY rule part MUST NOT be specified when the FREQ rule part is set to WEEKLY.
    For example, "FREQ=MONTHLY;BYMONTHDAY=15,-1" indicates a monthly recurrence rule on the 15th and the last day of the month
  • BYYEARDAY, {string} The BYYEARDAY rule part specifies a COMMA-separated list of days of the year. Valid values are 1 to 366 or -366 to -1. For example, -1 represents the last day of the year (December 31st) and -306 represents the 306th to the last day of the year (March 1st). The BYYEARDAY rule part MUST NOT be specified when the FREQ rule part is set to DAILY, WEEKLY, or MONTHLY.
    For example, "FREQ=YEARLY;BYYEARDAY=100,200" indicates a yearly recurrence rule on the 100th and 200th days of the year
  • BYSETPOS, {string} The BYSETPOS rule part specifies a COMMA-separated list of values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule. BYSETPOS operates on a set of recurrence instances in one interval of the recurrence rule. For example, in a WEEKLY rule, the interval would be one week A set of recurrence instances starts at the beginning of the interval defined by the FREQ rule part. Valid values are 1 to 366 or -366 to -1. It MUST only be used in conjunction with another BYxxx rule part. For example "the last work day of the month" could be represented as: FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 Each BYSETPOS value can include a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific occurrence within the set of occurrences specified by the rule.
    For example, "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1" indicates a monthly recurrence rule on the last work day of the month
  • BYMONTH, {string} The BYMONTH rule part specifies a COMMA-separated list of months of the year. Valid values are 1 to 12.
    For example, "FREQ=YEARLY;BYMONTH=1,6,12" indicates a yearly recurrence rule on January, June and December
  • BYHOUR, {string} The BYHOUR rule part specifies a COMMA-separated list of hours of the day. Valid values are 0 to 23.
    For example, "FREQ=DAILY;BYHOUR=9,14,18" indicates a daily recurrence rule at 09:00 AM, 02:00 PM and 06:00 PM
  • BYMINUTE, {string} The BYMINUTE rule part specifies a COMMA-separated list of minutes within an hour. Valid values are 0 to 59.
    For example, "FREQ=HOURLY;BYMINUTE=0,30" indicates an hourly recurrence rule at minute 0 and minute 30 of each hour
  • BYSECOND, {string} The BYSECOND rule part specifies a COMMA-separated list of seconds within a minute. Valid values are 0 to 60.
    For example, "FREQ=MINUTELY;BYSECOND=0,15,30,45" indicates a minutely recurrence rule at second 0, second 15, second 30 and second 45 of each minute
Returns:
Returns the object itself, as an object of IRecur type
Type
IRecur
Example
The following code parses the expression of "FREQ=WEEKLY;BYDAY=MO,WE" and checks if the parsing is successful and the rules are valid. If not, it gets the parsing error details:

 var oRecur = exontrol.ICalendar.IRecur.Parse("FREQ=WEEKLY;BYDAY=MO,WE");
 if ( oRecur.valid() )
 {
   // the parsing is successful and the rules are valid, do something with oRecur
 }
parse

valid() → {boolean}

The valid() method checks whether the current recurrence-expression is valid. The method returns true if the expression is valid, or false if the expression is invalid. An invalid expression includes an empty expression, missing FREQ rule, invalid FREQ value, unknown rule or invalid rule value. The error() method can be used to get the description of the parsing error. The valid() method should be used after the IRecur object is created, to check whether the expression is valid or not. The get() method can be used to get the value of a rule, if the expression is valid. The has() method can be used to check whether a rule exists, if the expression is valid.
Returns:
Returns true if the recurrence-expression is valid, else returns false
Type
boolean
Example
The following example creates a recurrence rule with "FREQ=DAILY;INTERVAL=2;COUNT=5" expression, checks whether the expression is valid and gets the error description if the expression is invalid:

 var oRecur = new IRecur("FREQ=DAILY;INTERVAL=2;COUNT=5");
 if ( oRecur.valid() )
  console.log("The expression is valid.");
 else
  console.log("The expression is invalid. Error: " + oRecur.error());

The sample output of the above code is:

 The expression is valid.
valid

(static) Parse(expression, optionsopt) → {IRecur}

The Parse() method parses the giving recurrence-rules and returns an object of IRecur type. The Parse() method also caches the parsed expression, so if the same expression is parsed again, the cached IRecur object is returned instead of parsing the expression again. This caching mechanism improves performance when the same recurrence rules are used multiple times. The valid() method can be used to check if the parsing was successful or if there were any errors in the RRULE expression. If the expression is valid, you can then call the all() method to retrieve the occurrences generated by the rule.
Parameters:
Name Type Attributes Description
expression string | object Indicates the recurrence-expression to parse, as:
  • a string of "rule=value;..." RRULE format, as defined in RFC 5545. The rules can be in any order, separated by ; (semi-colon) character and could be as follows:
    • FREQ, {string} The FREQ rule part identifies the type of recurrence rule. This rule part MUST be specified in the recurrence rule.
      The valid values are "SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY", "MONTHLY" and "YEARLY", as explained:
      • SECONDLY, to specify repeating events based on an interval of a second or more
      • MINUTELY, to specify repeating events based on an interval of a minute or more
      • HOURLY, to specify repeating events based on an interval of an hour or more
      • DAILY, to specify repeating events based on an interval of a day or more
      • WEEKLY, to specify repeating events based on an interval of a week or more
      • MONTHLY, to specify repeating events based on an interval of a month or more
      • YEARLY, to specify repeating events based on an interval of a year or more

      For example, "FREQ=DAILY;" indicates a daily recurrence rule.

    • DTSTART, {Date} The DTSTART rule specifies the date the recurrence starts from, in YYYYMMDD[THHNNSS[Z]] format. If missing the current date and time is used.
      The format supports:
      • DATE format, as YYYYMMDD (for example, 20220101 indicates January 1st, 2022)
      • DATE-TIME format, as YYYYMMDDTHHNNSS (for example, 20220101T090000 indicates January 1st, 2022, at 09:00 AM local time)
      • DATE-TIME in UTC format, as YYYYMMDDTHHNNSSZ (for example, 20220101T090000Z indicates January 1st, 2022, at 09:00 AM UTC)
      where:
      • YYYY indicates the year
      • MM indicates the month (01 = January, 02 = February, ..., 12 = December)
      • DD indicates the day of the month (01 through 31)
      • T character is used to separate the date and time portions of the value
      • HH indicates the hour (00 through 23)
      • NN indicates the minute (00 through 59)
      • SS indicates the second (00 through 60)
      • Z character indicates that the time is in UTC format.

      For example, "FREQ=DAILY;DTSTART=20220101T090000Z;" indicates a daily recurrence rule starting from January 1st, 2022, at 09:00 AM UTC.

    • INTERVAL {number} The INTERVAL rule part contains a positive integer representing at which intervals the recurrence rule repeats.
      The default value is "1", meaning:
      • every 1 second for a SECONDLY rule
      • every 1 minute for a MINUTELY rule
      • every 1 hour for an HOURLY rule
      • every 1 day for a DAILY rule
      • every 1 week for a WEEKLY rule
      • every 1 month for a MONTHLY rule
      • every 1 year for a YEARLY rule
      For example, "FREQ=DAILY;INTERVAL=8" indicates a recurrence rule every eight days
    • COUNT, {number} The COUNT rule part defines the number of occurrences at which to range-bound the recurrence. The DTSTART property value always counts as the first occurrence. The COUNT rule part is a positive integer.
      For example, "FREQ=DAILY;COUNT=10" indicates a recurrence rule for 10 times
    • WKST, {string} The WKST rule part specifies the day on which the workweek starts. The default value is MO. The WKST rule part is significant when a WEEKLY "RRULE" has an interval greater than 1, and a BYDAY rule part is specified. This is also significant when in a YEARLY "RRULE" when a BYWEEKNO rule part is specified.
      Valid values are:
      • MO, for Monday
      • TU, for Tuesday
      • WE, for Wednesday
      • TH, for Thursday
      • FR, for Friday
      • SA, for Saturday
      • SU, for Sunday

      For example, "FREQ=WEEKLY;WKST=SU" indicates a weekly recurrence rule where the week starts on Sunday

    • UNTIL, {Date} The UNTIL rule part defines a DATE or DATE-TIME value that bounds the recurrence rule in an inclusive manner. If the value specified by UNTIL is synchronized with the specified recurrence, this DATE or DATE-TIME becomes the last instance of the recurrence.
      The format of UNTIL is YYYYMMDD[THHNNSS[Z]], supporting:
      • DATE format, as YYYYMMDD (for example, 20220101 indicates January 1st, 2022)
      • DATE-TIME format, as YYYYMMDDTHHNNSS (for example, 20220101T090000 indicates January 1st, 2022, at 09:00 AM local time)
      • DATE-TIME in UTC format, as YYYYMMDDTHHNNSSZ (for example, 20220101T090000Z indicates January 1st, 2022, at 09:00 AM UTC)
      where:
      • YYYY indicates the year
      • MM indicates the month (01 = January, 02 = February, ..., 12 = December)
      • DD indicates the day of the month (01 through 31)
      • T character is used to separate the date and time portions of the value
      • HH indicates the hour (00 through 23)
      • NN indicates the minute (00 through 59)
      • SS indicates the second (00 through 60)
      • Z character indicates that the time is in UTC format.

      For example, "FREQ=DAILY;UNTIL=20220110T090000Z" indicates a daily recurrence rule until January 10th, 2022, at 09:00 AM UTC.

    • BYWEEKNO, {string} The BYWEEKNO rule part specifies a COMMA-separated list of ordinals specifying weeks of the year. Valid values are 1 to 53 or -53 to -1. The week numbering follows the ISO 8601 standard, where the first week of the year is the week that contains the first Thursday of the year. For example, week number 1 is the week with the first Thursday in January. Week number 52 is the week with the last Thursday in December. Week number 53 is only used in years where January 1st is a Thursday or a leap year where January 1st is a Wednesday. The BYWEEKNO rule part MUST NOT be specified when the FREQ rule part is set to DAILY, WEEKLY, or MONTHLY.
      For example, "FREQ=YEARLY;BYWEEKNO=20,30" indicates a yearly recurrence rule on the 20th and 30th weeks of the year
    • BYDAY, {string} The BYDAY rule part specifies a COMMA-separated list of days of the week. Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific day within the MONTHLY or YEARLY "RRULE". For example, within a MONTHLY rule, +1MO indicates the first Monday of the month, whereas -1MO indicates the last Monday of the month. Within a YEARLY rule, +3TU indicates the third Tuesday of the year. Valid values for n are 1 to 5 or -5 to -1. The BYDAY rule part MUST NOT be specified when the FREQ rule part is set to DAILY.
      Valid values are:
      • MO, for Monday
      • TU, for Tuesday
      • WE, for Wednesday
      • TH, for Thursday
      • FR, for Friday
      • SA, for Saturday
      • SU, for Sunday

      For example, "FREQ=WEEKLY;BYDAY=MO,WE,FR" indicates a weekly recurrence rule on Monday, Wednesday and Friday

    • BYMONTHDAY, {string} The BYMONTHDAY rule part specifies a COMMA-separated list of days of the month. Valid values are 1 to 31 or -31 to -1. For example, -10 represents the tenth to the last day of the month. The BYMONTHDAY rule part MUST NOT be specified when the FREQ rule part is set to WEEKLY.
      For example, "FREQ=MONTHLY;BYMONTHDAY=15,-1" indicates a monthly recurrence rule on the 15th and the last day of the month
    • BYYEARDAY, {string} The BYYEARDAY rule part specifies a COMMA-separated list of days of the year. Valid values are 1 to 366 or -366 to -1. For example, -1 represents the last day of the year (December 31st) and -306 represents the 306th to the last day of the year (March 1st). The BYYEARDAY rule part MUST NOT be specified when the FREQ rule part is set to DAILY, WEEKLY, or MONTHLY.
      For example, "FREQ=YEARLY;BYYEARDAY=100,200" indicates a yearly recurrence rule on the 100th and 200th days of the year
    • BYSETPOS, {string} The BYSETPOS rule part specifies a COMMA-separated list of values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule. BYSETPOS operates on a set of recurrence instances in one interval of the recurrence rule. For example, in a WEEKLY rule, the interval would be one week A set of recurrence instances starts at the beginning of the interval defined by the FREQ rule part. Valid values are 1 to 366 or -366 to -1. It MUST only be used in conjunction with another BYxxx rule part. For example "the last work day of the month" could be represented as: FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 Each BYSETPOS value can include a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific occurrence within the set of occurrences specified by the rule.
      For example, "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1" indicates a monthly recurrence rule on the last work day of the month
    • BYMONTH, {string} The BYMONTH rule part specifies a COMMA-separated list of months of the year. Valid values are 1 to 12.
      For example, "FREQ=YEARLY;BYMONTH=1,6,12" indicates a yearly recurrence rule on January, June and December
    • BYHOUR, {string} The BYHOUR rule part specifies a COMMA-separated list of hours of the day. Valid values are 0 to 23.
      For example, "FREQ=DAILY;BYHOUR=9,14,18" indicates a daily recurrence rule at 09:00 AM, 02:00 PM and 06:00 PM
    • BYMINUTE, {string} The BYMINUTE rule part specifies a COMMA-separated list of minutes within an hour. Valid values are 0 to 59.
      For example, "FREQ=HOURLY;BYMINUTE=0,30" indicates an hourly recurrence rule at minute 0 and minute 30 of each hour
    • BYSECOND, {string} The BYSECOND rule part specifies a COMMA-separated list of seconds within a minute. Valid values are 0 to 60.
      For example, "FREQ=MINUTELY;BYSECOND=0,15,30,45" indicates a minutely recurrence rule at second 0, second 15, second 30 and second 45 of each minute
  • an object of {dtstart, freq, until, count, interval, bysecond, byminute, byhour, byday, bymonthday, byyearday, byweekno, bymonth, bysetpos, wkst} type, where:
    • dtstart {Date}, specifies the date the recurrence starts from (in YYYYMMDD[THHNNSS[Z]] format)
    • freq {string}, specifies the frequency of the recurrence rule. Valid values include "SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY", "MONTHLY" and "YEARLY"
    • until {Date}, specifies the date that bounds the recurrence rule in an inclusive manner (in YYYYMMDD[THHNNSS[Z]] format)
    • count {number}, specifies the number of occurrences at which to range-bound the recurrence
    • interval {number}, specifies a positive integer representing at which intervals the recurrence rule repeats
    • bysecond {string}, specifies a COMMA-separated list of seconds within a minute (valid values are 0 to 60)
    • byminute {string}, specifies a COMMA-separated list of minutes within an hour (valid values are 0 to 59)
    • byhour {string}, specifies a COMMA-separated list of hours of the day (valid values are 0 to 23)
    • byday {string}, specifies a COMMA-separated list of days of the week (each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer)
    • bymonthday {string}, specifies a COMMA-separated list of days of the month (valid values are 1 to 31 or -31 to -1)
    • byyearday {string}, specifies a COMMA-separated list of days of the year (valid values are 1 to 366 or -366 to -1)
    • byweekno {string}, specifies a COMMA-separated list of ordinals specifying weeks of the year (valid values are 1 to 53 or -53 to -1)
    • bymonth {string}, specifies a COMMA-separated list of months of the year (valid values are 1 to 12)
    • bysetpos {string}, specifies a COMMA-separated list of values that corresponds to the nth occurrence within the set of recurrence instances specified by the rule (valid values are 1 to 366 or -366 to -1)
    • wkst {string}, specifies the day on which the workweek starts (valid values are "MO", "TU", "WE", "TH", "FR", "SA" and "SU")
options IRecurOptions <optional>
Specifies the options to create the parsing object, as an object of {exontrol.ICalendar.IRecurOptions} type.
Returns:
Returns an object of IRecur type
Type
IRecur
Example
exontrol.ICalendar.IRecur.Parse("FREQ=WEEKLY;BYDAY=MO,WE") or exontrol.ICalendar.IRecur.Parse({FREQ:"WEEKLY",BYDAY:"MO,WE"}), every week on Monday, Wednesday
exontrol.ICalendar.IRecur.Parse("FREQ=DAILY;INTERVAL=3;COUNT=10"), every 3 days for 10 times
exontrol.ICalendar.IRecur.Parse("FREQ=MONTHLY;BYMONTHDAY=10,15;COUNT=20"), every month on the 10th and 15th for 20 times
Parse