DateTimeExtensions Class
Provides extension methods for instances of DateTime.
public static class DateTimeExtensionsMethods
| Name | Description |
|---|---|
| DateTime.GetEndOfDay() | Given a date and time, returns the last tick of the day. |
| DateTime.GetEndOfMonth() | Given a date and time, returns the last tick of the last day of the same month. |
| DateTime.GetEndOfWeek() | Given a date and time, returns the last tick of the last day of the same week, according to the current culture. |
| DateTime.GetEndOfWeek(DayOfWeek) | Returns the last tick of the earliest date, greater or equal to a given date, whose day of the week is the one preceding a specified day of the week. |
| DateTime.GetEndOfWeek(CultureInfo) | Given a date and time, returns the last tick of the last day of the same week, according to the specified culture. |
| DateTime.GetEndOfWeek(DateTimeFormatInfo) | Given a date and time, returns the last tick of the last day of the same week, according to the specified formatting information. |
| DateTime.GetLastDayOfMonth() | Given a date and time, returns midnight on the last day of the same month. |
| DateTime.GetLastDayOfWeek() | Given a date and time, returns midnight on the last day of the same week, according to the current culture. |
| DateTime.GetLastDayOfWeek(DayOfWeek) | Returns midnight on the earliest date, greater or equal to a given date and time, whose day of the week is the one preceding a specified day of the week. |
| DateTime.GetLastDayOfWeek(CultureInfo) | Given a date and time, returns midnight on the last day of the same week, according to the specified culture. |
| DateTime.GetLastDayOfWeek(DateTimeFormatInfo) | Given a date and time, returns midnight on the last day of the same week, according to the specified formatting information. |
| DateTime.GetStartOfMonth() | Given a date and time, returns midnight on the first day of the same month. |
| DateTime.GetStartOfWeek() | Given a date and time, returns midnight on the first day of the same week, according to the current culture. |
| DateTime.GetStartOfWeek(DayOfWeek) | Returns midnight on the most recent date, earlier or equal to a given date, whose day of the week is equal to a specified day of the week. |
| DateTime.GetStartOfWeek(CultureInfo) | Given a date and time, returns midnight on the first day of the same week, according to the specified culture. |
| DateTime.GetStartOfWeek(DateTimeFormatInfo) | Given a date and time, returns midnight on the first day of the same week, according to the specified formatting information. |
DateTime.GetEndOfDay()
DateTime.GetEndOfMonth()
Given a date and time, returns the last tick of the last day of the same month.
DateTime.GetEndOfWeek overloads
DateTime.GetEndOfWeek()
DateTime.GetEndOfWeek(DayOfWeek)
Returns the last tick of the earliest date, greater or equal to a given date, whose day of the week is the one preceding a specified day of the week.
Parameters
thisDateTime- The instance of
DateTimeon which this method is called. firstDayOfWeekDayOfWeek- A
DayOfWeekvalue representing the day that starts the week.
Returns
DateTime An instance of DateTime whose value represents the last day of the week of this, if weeks are considered starting with firstDayOfWeek.
See also
DateTime.GetEndOfWeek(CultureInfo)
Given a date and time, returns the last tick of the last day of the same week, according to the specified culture.
extension(DateTime @this)
{
public DateTime GetEndOfWeek(CultureInfo culture)
}Parameters
thisDateTime- The instance of
DateTimeon which this method is called. cultureCultureInfo- An object that supplies culture-specific information.
Returns
DateTime An instance of DateTime whose value represents the last day of the week of this, according to culture.
Exceptions
ArgumentNullExceptioncultureisnull.
See also
DateTime.GetEndOfWeek(DateTimeFormatInfo)
Given a date and time, returns the last tick of the last day of the same week, according to the specified formatting information.
extension(DateTime @this)
{
public DateTime GetEndOfWeek(DateTimeFormatInfo dateTimeFormat)
}Parameters
thisDateTime- The instance of
DateTimeon which this method is called. dateTimeFormatDateTimeFormatInfo- An object that supplies culture-specific date formatting information.
Returns
DateTime An instance of DateTime whose value represents the last day of the week of this, according to dateTimeFormat.
Exceptions
ArgumentNullExceptiondateTimeFormatisnull.
See also
DateTime.GetLastDayOfMonth()
Given a date and time, returns midnight on the last day of the same month.
DateTime.GetLastDayOfWeek overloads
DateTime.GetLastDayOfWeek()
DateTime.GetLastDayOfWeek(DayOfWeek)
Returns midnight on the earliest date, greater or equal to a given date and time, whose day of the week is the one preceding a specified day of the week.
Parameters
thisDateTime- The instance of
DateTimeon which this method is called. firstDayOfWeekDayOfWeek- A
DayOfWeekvalue representing the day that starts the week.
Returns
DateTime An instance of DateTime whose value represents the last day of the week of this, if weeks are considered starting with firstDayOfWeek.
See also
DateTime.GetLastDayOfWeek(CultureInfo)
Given a date and time, returns midnight on the last day of the same week, according to the specified culture.
extension(DateTime @this)
{
public DateTime GetLastDayOfWeek(CultureInfo culture)
}Parameters
thisDateTime- The instance of
DateTimeon which this method is called. cultureCultureInfo- An object that supplies culture-specific information.
Returns
DateTime An instance of DateTime whose value represents the last day of the week of this, according to culture.
Exceptions
ArgumentNullExceptioncultureisnull.
See also
DateTime.GetLastDayOfWeek(DateTimeFormatInfo)
Given a date and time, returns midnight on the last day of the same week, according to the specified formatting information.
extension(DateTime @this)
{
public DateTime GetLastDayOfWeek(DateTimeFormatInfo dateTimeFormat)
}Parameters
thisDateTime- The instance of
DateTimeon which this method is called. dateTimeFormatDateTimeFormatInfo- An object that supplies culture-specific date formatting information.
Returns
DateTime An instance of DateTime whose value represents the last day of the week of this, according to dateTimeFormat.
Exceptions
ArgumentNullExceptiondateTimeFormatisnull.
See also
DateTime.GetStartOfMonth()
Given a date and time, returns midnight on the first day of the same month.
DateTime.GetStartOfWeek overloads
DateTime.GetStartOfWeek()
DateTime.GetStartOfWeek(DayOfWeek)
Returns midnight on the most recent date, earlier or equal to a given date, whose day of the week is equal to a specified day of the week.
Parameters
thisDateTime- The instance of
DateTimeon which this method is called. firstDayOfWeekDayOfWeek- A
DayOfWeekvalue representing the day that starts the week.
Returns
DateTime An instance of DateTime whose value represents the first day of the week of this, if weeks are considered starting with firstDayOfWeek.
See also
DateTime.GetStartOfWeek(CultureInfo)
Given a date and time, returns midnight on the first day of the same week, according to the specified culture.
extension(DateTime @this)
{
public DateTime GetStartOfWeek(CultureInfo culture)
}Parameters
thisDateTime- The instance of
DateTimeon which this method is called. cultureCultureInfo- An object that supplies culture-specific information.
Returns
DateTime An instance of DateTime whose value represents the first day of the week of this, according to culture.
Exceptions
ArgumentNullExceptioncultureisnull.
See also
DateTime.GetStartOfWeek(DateTimeFormatInfo)
Given a date and time, returns midnight on the first day of the same week, according to the specified formatting information.
extension(DateTime @this)
{
public DateTime GetStartOfWeek(DateTimeFormatInfo dateTimeFormat)
}Parameters
thisDateTime- The instance of
DateTimeon which this method is called. dateTimeFormatDateTimeFormatInfo- An object that supplies culture-specific date formatting information.
Returns
DateTime An instance of DateTime whose value represents the first day of the week of this, according to dateTimeFormat.
Exceptions
ArgumentNullExceptiondateTimeFormatisnull.