Represents Nth occurrence (or all occurrences) of the specified day of the week.
For a list of all members of this type, see ByDay Members.
System.Object
Aspose.iCalendar.ByDay
[Visual Basic]
Public Class ByDay
Remarks
Corresponds to one day of the week specified in the BYDAY part of a recurrence rule.
Can be used in a monthly or yearly recurrence rule to specify Nth occurrence (or all occurrences) of the specified day of the week in a month or year.
BYDAY=MO represents all Mondays of the month or year. To represent all occurrences, set NthOccurrence to 0.
BYDAY=2MO represents 2nd Monday in a month or year.
BYDAY=-1MO represents the last Monday of a month or year.
Example
Weekly on Tuesday and Thursday for 5 weeks:
[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.Weekly;
rule.Until = new DateTime(1997, 10, 7);
rule.ByDay.Add(new ByDay(DayOfWeek.Tuesday));
rule.ByDay.Add(new ByDay(DayOfWeek.Thursday));
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=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH");
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.Weekly
rule.Until = New DateTime(1997, 10, 7)
rule.ByDay.Add(New ByDay(DayOfWeek.Tuesday))
rule.ByDay.Add(New ByDay(DayOfWeek.Thursday))
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=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH")
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
ByDay Members | Aspose.iCalendar Namespace | ByDayCollection