Skip to main content

TimeOfDayInterval(TimeSpan, TimeSpan) Constructor

Initializes a new instance of the TimeOfDayInterval class with the specified start time and end time.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v24.1.Core.dll

NuGet Package: DevExpress.Scheduler.Core

Declaration

public TimeOfDayInterval(
    TimeSpan start,
    TimeSpan end
)

Parameters

Name Type Description
start TimeSpan

A TimeSpan value which specifies the start time of the interval. This value is assigned to the TimeOfDayInterval.Start property.

end TimeSpan

A TimeSpan value which specifies the end time of the interval. This value is assigned to the TimeOfDayInterval.End property.

Remarks

Note that the end parameter value should be greater than or equal to the start parameter value, otherwise an exception will be thrown. Also, the start.Ticks and end.Ticks should be greater than or equal to 0.

Example

This example demonstrates how the TimeOfDayInterval object can be converted to a TimeInterval object. To do this the TimeOfDayInterval.ToTimeInterval method is used.

The initial TimeOfDayInterval value:

09:35:00 - 12:54:00 [03:19:00]

Converted to TimeInterval:

1/1/0001 9:35:00 - 1/1/0001 12:54:00 [03:19:00]

Converted to TimeInterval with July 17, 2010 as the start date parameter:

17/7/2010 9:35:00 - 17/7/2010 12:54:00 [03:19:00]

Use the following code to achieve these results.

using DevExpress.XtraScheduler;
// ...

// Initialize a new "time-of-day" interval.
// Start = 9:35. End = 12:54.
TimeOfDayInterval tOfDayInterval = new TimeOfDayInterval(new TimeSpan(9, 35, 0), 
    new TimeSpan(12, 54, 0));

// Convert to time interval starting from DateTime.MinValue.
textBox1.Text = tOfDayInterval.ToTimeInterval().ToString();

// Convert to time interval starting from the specified date (July 17, 2010).
textBox2.Text = tOfDayInterval.ToTimeInterval(new DateTime(2010, 7, 17)).ToString();
See Also