New to Telerik UI for WinForms? Start a free 30-day trial

Provides date-boundary and navigation calculations used by scheduler views and recurrence rules.

Definition

Namespace:Telerik.WinControls.UI

Assembly:Telerik.WinControls.Scheduler.dll

Syntax:

C#
public static class DateHelper

Inheritance: objectDateHelper

Methods

Moves a date by the requested navigation unit using the scheduler's calendar. Week steps add seven days per step; day and unrecognized values use day arithmetic.

C#
public static DateTime GetDateWithOffset(DateTime date, NavigationStepTypes navigationStepType, int navigationStep, RadScheduler scheduler)
Parameters:dateDateTime

The date from which to calculate.

navigationStepTypeNavigationStepTypes

The minute, hour, day, week, month, or year unit to apply; unrecognized values use days.

navigationStepint

The signed number of steps to apply.

schedulerRadScheduler

The scheduler whose culture calendar performs the date arithmetic.

Returns:

DateTime

The date after applying the requested calendar offset.

Returns the specified date at 23:59:59.

C#
public static DateTime GetEndOfDay(DateTime day)
Parameters:dayDateTime

The date whose day boundary is required.

Returns:

DateTime

The same calendar date at 23:59:59; subsecond precision is not included.

Returns the last day of the date's calendar month at 23:59:59.

C#
public static DateTime GetEndOfMonth(DateTime date, DateTimeFormatInfo dateTimeFormat)
Parameters:dateDateTime

A date in the month to inspect.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar used to determine the month's length.

Returns:

DateTime

The last day of the containing month at 23:59:59.

Returns the exclusive boundary after the week containing the date, using the specified first weekday.

C#
public static DateTime GetEndOfWeek(DateTime date, DateTimeFormatInfo dateTimeFormat, DayOfWeek weekStart)
Parameters:dateDateTime

A date in the week to inspect.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar used to resolve the date's weekday.

weekStartDayOfWeek

The weekday that begins the week.

Returns:

DateTime

Midnight at the start of the following week.

Returns the exclusive boundary after the week containing the date, using the culture's configured first weekday.

C#
public static DateTime GetEndOfWeek(DateTime date, DateTimeFormatInfo dateTimeFormat)
Parameters:dateDateTime

A date in the week to inspect.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar and first weekday.

Returns:

DateTime

Midnight at the start of the following week.

Calculates a year-end value using the supplied calendar's year length and the Gregorian Year anchor.

C#
public static DateTime GetEndOfYear(DateTime date, DateTimeFormatInfo dateTimeFormat)
Parameters:dateDateTime

A date in the year to inspect.

dateTimeFormatDateTimeFormatInfo

The calendar used to obtain the year length.

Returns:

DateTime

The calculated year-end value at 23:59:59.

The Gregorian year anchor may not align with dateTimeFormat's year when it is a non-Gregorian calendar.

Counts the week-sized rows needed to display the month containing the date. The first and last partial weeks are included.

C#
public static int GetMonthDisplayWeeks(DateTime date, DateTimeFormatInfo dateTimeFormat)
Parameters:dateDateTime

A date in the month to display.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar and first weekday used for the row boundaries.

Returns:

int

The number of seven-day display weeks spanning the month.

Returns midnight on the first day of the month containing the date, according to the supplied calendar.

C#
public static DateTime GetStartOfMonth(DateTime date, DateTimeFormatInfo dateTimeFormat)
Parameters:dateDateTime

A date in the month to inspect.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar used to resolve the month.

Returns:

DateTime

The first day of the containing month at midnight.

Returns midnight on the first day of the Gregorian month containing the date.

C#
public static DateTime GetStartOfMonth(DateTime date)
Parameters:dateDateTime

A date in the month to inspect.

Returns:

DateTime

The first day of the containing month at midnight.

Returns midnight at the start of the week containing the date, using the specified first weekday.

C#
public static DateTime GetStartOfWeek(DateTime date, DateTimeFormatInfo dateTimeFormat, DayOfWeek weekStart)
Parameters:dateDateTime

A date in the week to inspect.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar used to resolve the date's weekday.

weekStartDayOfWeek

The weekday that begins the week.

Returns:

DateTime

The start date of the containing week.

Returns midnight at the start of the week containing the date, using the culture's configured first weekday.

C#
public static DateTime GetStartOfWeek(DateTime date, DateTimeFormatInfo dateTimeFormat)
Parameters:dateDateTime

A date in the week to inspect.

dateTimeFormatDateTimeFormatInfo

The culture-specific calendar and first weekday.

Returns:

DateTime

The start date of the containing week.

Returns midnight on January 1 of the Gregorian year containing the date.

C#
public static DateTime GetStartOfYear(DateTime date)
Parameters:dateDateTime

A date in the year to inspect.

Returns:

DateTime

January 1 of the containing Gregorian year at midnight.