WeeklyRecurrenceRule
Occurrences of this rule repeat on a weekly basis.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
public class WeeklyRecurrenceRule : RecurrenceRule, ISerializable, IEquatable<RecurrenceRule>
Inheritance: objectRecurrenceRuleWeeklyRecurrenceRule
Implements:
Inherited Members
Example:
using System;
using Telerik.Web.UI;
namespace RecurrenceExamples
{
class WeeklyRecurrenceRuleExample
{
static void Main()
{
// Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour.
Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"),
Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment");
// Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
RecurrenceRange range = new RecurrenceRange();
range.Start = recurringAppointment.Start;
range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
range.MaxOccurrences = 10;
// Creates a recurrence rule to repeat the appointment every two weeks on Mondays and Tuesdays.
RecurrenceDay mask = RecurrenceDay.Monday | RecurrenceDay.Tuesday;
WeeklyRecurrenceRule rrule = new WeeklyRecurrenceRule(2, mask, range);
Console.WriteLine("Appointment occurrs at the following times: ");
int ix = 0;
foreach (DateTime occurrence in rrule.Occurrences)
{
ix = ix + 1;
Console.WriteLine("{0,2}: {1} ({2})", ix, occurrence.ToLocalTime(), occurrence.DayOfWeek);
}
}
}
}
/*
This example produces the following results:
Appointment occurrs at the following times:
1: 6/4/2007 3:30:00 PM (Monday)
2: 6/5/2007 3:30:00 PM (Tuesday)
3: 6/18/2007 3:30:00 PM (Monday)
4: 6/19/2007 3:30:00 PM (Tuesday)
5: 7/2/2007 3:30:00 PM (Monday)
6: 7/3/2007 3:30:00 PM (Tuesday)
7: 7/16/2007 3:30:00 PM (Monday)
8: 7/17/2007 3:30:00 PM (Tuesday)
9: 7/30/2007 3:30:00 PM (Monday)
10: 7/31/2007 3:30:00 PM (Tuesday)
*/
Imports System
Imports Telerik.Web.UI
Namespace RecurrenceExamples
Class WeeklyRecurrenceRuleExample
Shared Sub Main()
' Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour.
Dim recurringAppointment As New Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"), Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment")
' Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment.
Dim range As New RecurrenceRange()
range.Start = recurringAppointment.Start
range.EventDuration = recurringAppointment.[End] - recurringAppointment.Start
range.MaxOccurrences = 10
' Creates a recurrence rule to repeat the appointment every two weeks on Mondays and Tuesdays.
Dim mask As RecurrenceDay = RecurrenceDay.Monday Or RecurrenceDay.Tuesday
Dim rrule As New WeeklyRecurrenceRule(2, mask, range)
Console.WriteLine("Appointment occurrs at the following times: ")
Dim ix As Integer = 0
For Each occurrence As DateTime In rrule.Occurrences
ix = ix + 1
Console.WriteLine("{0,2}: {1} ({2})", ix, occurrence.ToLocalTime(), occurrence.DayOfWeek)
Next
End Sub
End Class
End Namespace
'
'This example produces the following results:
'
'Appointment occurrs at the following times:
' 1: 6/4/2007 3:30:00 PM (Monday)
' 2: 6/5/2007 3:30:00 PM (Tuesday)
' 3: 6/18/2007 3:30:00 PM (Monday)
' 4: 6/19/2007 3:30:00 PM (Tuesday)
' 5: 7/2/2007 3:30:00 PM (Monday)
' 6: 7/3/2007 3:30:00 PM (Tuesday)
' 7: 7/16/2007 3:30:00 PM (Monday)
' 8: 7/17/2007 3:30:00 PM (Tuesday)
' 9: 7/30/2007 3:30:00 PM (Monday)
'10: 7/31/2007 3:30:00 PM (Tuesday)
'
Constructors
Initializes a new instance of WeeklyRecurrenceRule with the specified interval, days of week bit mask and RecurrenceRange.
public WeeklyRecurrenceRule(int interval, RecurrenceDay daysOfWeekMask, RecurrenceRange range, DayOfWeek firstDayOfWeek)
The number of weeks between the occurrences.
daysOfWeekMaskRecurrenceDayA bit mask that specifies the week days on which the event recurs.
rangeRecurrenceRangeThe RecurrenceRange instance that specifies the range of this rule.
firstDayOfWeekDayOfWeekThe first day of week to use for calculations.
Initializes a new instance of WeeklyRecurrenceRule with the specified interval, days of week bit mask and RecurrenceRange.
public WeeklyRecurrenceRule(int interval, RecurrenceDay daysOfWeekMask, RecurrenceRange range)
The number of weeks between the occurrences.
daysOfWeekMaskRecurrenceDayA bit mask that specifies the week days on which the event recurs.
rangeRecurrenceRangeThe RecurrenceRange instance that specifies the range of this rule.
Properties
Gets the bit mask that specifies the week days on which the event recurs.
public RecurrenceDay DaysOfWeekMask { get; }
A bit mask that specifies the week days on which the event recurs.
For additional information on how to create masks see the RecurrenceDay documentation.