Represents one recurrence or exception rule in a recurrence pattern.
For a list of all members of this type, see RecurrenceRule Members.
System.Object
Aspose.iCalendar.RecurrenceRule
[Visual Basic]
Public Class RecurrenceRule
[C#]public class RecurrenceRule
Remarks
Corresponds to RRULE or EXRULE part in iCalendar.
To construct a recurrence rule, you typically need to:
1. Specify the type of the rule in Frequency.
2. Specify how the recurrence pattern ends using EndType, Count or Until.
3. Specify values in one or more ByXXX collections.
Note, that if ByXXX rule part values are found which are beyond the available scope (ie, BYMONTHDAY=30 in February), they are simply ignored.
Information, not contained in the rule, necessary to determine the various recurrence instance start time and dates are derived from StartDate. For example, "FREQ=YEARLY;BYMONTH=1" doesn't specify a specific day within the month or a time. This information would be the same as what is specified for DTSTART.
ByXXX rule parts modify the recurrence in some manner. ByXXX rule parts for a period of time which is the same or greater than the frequency generally reduce or limit the number of occurrences of the recurrence generated. For example, "FREQ=DAILY;BYMONTH=1" reduces the number of recurrence instances from all days (if BYMONTH tag is not present) to all days in January. ByXXX rule parts for a period of time less than the frequency generally increase or expand the number of occurrences of the recurrence. For example, "FREQ=YEARLY;BYMONTH=1,2" increases the number of days within the yearly recurrence set from 1 (if BYMONTH tag is not present) to 2.
If multiple ByXXX rule parts are specified, then after evaluating the specified Frequency and Interval rule parts, the ByXXX rule parts are applied to the current set of evaluated occurrences in the following order: ByMonth, ByWeekNo, ByYearDay, ByMonthDay, ByDay, ByHour, ByMinute, BySecond and BySetPos; then Count and Until are evaluated.
Example
Every hour and a half for 4 occurrences:
[C#]
//Create the pattern programmatically.
RecurrencePattern pattern = new RecurrencePattern();
pattern.StartDate = new DateTime(1997, 9, 2, 9, 0, 0);
RecurrenceRule rule = pattern.RRules.Add();
rule.Frequency = Frequency.Minutely;
rule.Interval = 90;
rule.Count = 4;
DateCollection dates = pattern.GenerateOccurrences();
foreach (DateTime d in dates)
Console.WriteLine(d);
...
//Create the pattern from iCalendar string.
RecurrencePattern pattern = new RecurrencePattern(
"DTSTART;TZID=US-Eastern:19970902T090000\n" +
"RRULE:FREQ=MINUTELY;INTERVAL=90;COUNT=4");
DateCollection dates = pattern.GenerateOccurrences();
foreach (DateTime d in dates)
Console.WriteLine(d);
[VB]
'Create the pattern programmatically.
Dim pattern As RecurrencePattern = New RecurrencePattern
pattern.StartDate = New DateTime(1997, 9, 2, 9, 0, 0)
Dim rule As RecurrenceRule = pattern.RRules.Add()
rule.Frequency = Frequency.Minutely
rule.Interval = 90
rule.Count = 4
Dim dates As DateCollection = pattern.GenerateOccurrences()
For Each d As DateTime In dates
Console.WriteLine(d)
Next
...
'Create the pattern from iCalendar string.
Dim pattern As RecurrencePattern = New RecurrencePattern( _
"DTSTART;TZID=US-Eastern:19970902T090000" + ControlChars.CrLf + _
"RRULE:FREQ=MINUTELY;INTERVAL=90;COUNT=4")
Dim dates As DateCollection = pattern.GenerateOccurrences()
For Each d As DateTime In dates
Console.WriteLine(d)
Next
Requirements
Namespace: Aspose.iCalendar
Assembly: Aspose.iCalendar (in Aspose.iCalendar.dll)
See Also
RecurrenceRule Members | Aspose.iCalendar Namespace