HourlyRecurrenceRule
Class
Occurrences of this rule repeat every given number of hours.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
C#
public class HourlyRecurrenceRule : RecurrenceRule, ISerializable, IEquatable<RecurrenceRule>
Inheritance: objectRecurrenceRuleHourlyRecurrenceRule
Implements:
Inherited Members
Example:
csharp
using System;
using Telerik.Web.UI;
namespace RecurrenceExamples
{
class HourlyRecurrenceRuleExample
{
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 2 hours.
HourlyRecurrenceRule rrule = new HourlyRecurrenceRule(2, 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}", ix, occurrence.ToLocalTime());
}
}
}
}
/*
This example produces the following results:
Appointment occurrs at the following times:
1: 6/1/2007 3:30:00 PM
2: 6/1/2007 5:30:00 PM
3: 6/1/2007 7:30:00 PM
4: 6/1/2007 9:30:00 PM
5: 6/1/2007 11:30:00 PM
6: 6/2/2007 1:30:00 AM
7: 6/2/2007 3:30:00 AM
8: 6/2/2007 5:30:00 AM
9: 6/2/2007 7:30:00 AM
10: 6/2/2007 9:30:00 AM
*/
csharp
Imports System
Imports Telerik.Web.UI
Namespace RecurrenceExamples
Class HourlyRecurrenceRuleExample
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 2 hours.
Dim rrule As New HourlyRecurrenceRule(2, 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}", ix, occurrence.ToLocalTime())
Next
End Sub
End Class
End Namespace
'
'This example produces the following results:
'
'Appointment occurrs at the following times:
' 1: 6/1/2007 3:30:00 PM
' 2: 6/1/2007 5:30:00 PM
' 3: 6/1/2007 7:30:00 PM
' 4: 6/1/2007 9:30:00 PM
' 5: 6/1/2007 11:30:00 PM
' 6: 6/2/2007 1:30:00 AM
' 7: 6/2/2007 3:30:00 AM
' 8: 6/2/2007 5:30:00 AM
' 9: 6/2/2007 7:30:00 AM
'10: 6/2/2007 9:30:00 AM
'
Constructors
Initializes a new instance of the HourlyRecurrenceRule class with the specified interval (in hours) and RecurrenceRange.
C#
public HourlyRecurrenceRule(int interval, RecurrenceRange range)
The number of hours between the occurrences.
rangeRecurrenceRangeThe RecurrenceRange instance that specifies the range of this recurrence rule.