DateUtility Class

Provides utility methods to work with dates.

public static class DateUtility

Methods

NameDescription
GetDaysFromStartOfWeek(DayOfWeek)Returns the amount of full days separating a given day of the week from the first day of the same week, according to the current culture.
GetDaysFromStartOfWeek(DayOfWeek, DayOfWeek)Returns the amount of full days separating a given day of the week from the first day of the same week, if a given day is considered the first of the week.
GetDaysFromStartOfWeek(DayOfWeek, CultureInfo)Returns the amount of full days separating a given day of the week from the first day of the same week, according to the specified culture.
GetDaysFromStartOfWeek(DayOfWeek, DateTimeFormatInfo)Returns the amount of full days separating a given day of the week from the first day of the same week, according to the specified formatting information.

GetDaysFromStartOfWeek overloads

GetDaysFromStartOfWeek(DayOfWeek)

Returns the amount of full days separating a given day of the week from the first day of the same week, according to the current culture.

public static int GetDaysFromStartOfWeek(DayOfWeek today)
Parameters
today DayOfWeek
A DayOfWeek value.
Returns

int An integer number between 0 and 6 representing the days between the start of the week and today, according to the current culture.

See also

GetDaysFromStartOfWeek(DayOfWeek, DayOfWeek)

Returns the amount of full days separating a given day of the week from the first day of the same week, if a given day is considered the first of the week.

public static int GetDaysFromStartOfWeek(DayOfWeek today, DayOfWeek firstDayOfWeek)
Parameters
today DayOfWeek
A DayOfWeek value.
firstDayOfWeek DayOfWeek
A DayOfWeek value representing the day that starts the week.
Returns

int An integer number between 0 and 6 representing the days between the start of the week and today, if weeks are considered starting with firstDayOfWeek.

See also

GetDaysFromStartOfWeek(DayOfWeek, CultureInfo)

Returns the amount of full days separating a given day of the week from the first day of the same week, according to the specified culture.

public static int GetDaysFromStartOfWeek(DayOfWeek today, CultureInfo culture)
Parameters
today DayOfWeek
A DayOfWeek value.
culture CultureInfo
An object that supplies culture-specific information.
Returns

int An integer number between 0 and 6 representing the days between the start of the week and today, according to culture.

Exceptions
ArgumentNullException
culture is null.
See also

GetDaysFromStartOfWeek(DayOfWeek, DateTimeFormatInfo)

Returns the amount of full days separating a given day of the week from the first day of the same week, according to the specified formatting information.

public static int GetDaysFromStartOfWeek(DayOfWeek today, DateTimeFormatInfo dateTimeFormat)
Parameters
today DayOfWeek
A DayOfWeek value.
dateTimeFormat DateTimeFormatInfo
An object that supplies culture-specific date formatting information.
Returns

int An integer number between 0 and 6 representing the days between the start of the week and today, according to dateTimeFormat.

Exceptions
ArgumentNullException
dateTimeFormat is null.
See also