DateOnlyExtensions Class

Provides extension methods for instances of DateOnly.

This type is not available in the netstandard and .NET Framework builds of Louis, because their BCL has no DateOnly.

public static class DateOnlyExtensions

Methods

NameDescription
DateOnly.GetEndOfMonth()Given a date, returns the last day of the same month.
DateOnly.GetEndOfWeek()Given a date, returns the last day of the same week, according to the current culture.
DateOnly.GetEndOfWeek(DayOfWeek)Returns 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.
DateOnly.GetEndOfWeek(CultureInfo)Given a date, returns the last day of the same week, according to the specified culture.
DateOnly.GetEndOfWeek(DateTimeFormatInfo)Given a date, returns the last day of the same week, according to the specified formatting information.
DateOnly.GetStartOfMonth()Given a date, returns the first day of the same month.
DateOnly.GetStartOfWeek()Given a date, returns the first day of the same week, according to the current culture.
DateOnly.GetStartOfWeek(DayOfWeek)Returns 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.
DateOnly.GetStartOfWeek(CultureInfo)Given a date, returns the first day of the same week, according to the specified culture.
DateOnly.GetStartOfWeek(DateTimeFormatInfo)Given a date, returns the first day of the same week, according to the specified formatting information.

DateOnly.GetEndOfMonth()

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the last day of the same month.

extension(DateOnly @this)
{
    public DateOnly GetEndOfMonth()
}

Parameters

this DateOnly
The instance of DateOnly on which this method is called.

Returns

DateOnly An instance of DateOnly whose value represents the last day of the month of this.

DateOnly.GetEndOfWeek overloads

DateOnly.GetEndOfWeek()

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the last day of the same week, according to the current culture.

extension(DateOnly @this)
{
    public DateOnly GetEndOfWeek()
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
Returns

DateOnly An instance of DateOnly whose value represents the last day of the week of this, according to the current culture.

See also

DateOnly.GetEndOfWeek(DayOfWeek)

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Returns 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.

extension(DateOnly @this)
{
    public DateOnly GetEndOfWeek(DayOfWeek firstDayOfWeek)
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
firstDayOfWeek DayOfWeek
A DayOfWeek value representing the day that starts the week.
Returns

DateOnly An instance of DateOnly whose value represents the last day of the week of this, if weeks are considered starting with firstDayOfWeek.

See also

DateOnly.GetEndOfWeek(CultureInfo)

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the last day of the same week, according to the specified culture.

extension(DateOnly @this)
{
    public DateOnly GetEndOfWeek(CultureInfo culture)
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
culture CultureInfo
An object that supplies culture-specific information.
Returns

DateOnly An instance of DateOnly whose value represents the last day of the week of this, according to culture.

Exceptions
ArgumentNullException
culture is null.
See also

DateOnly.GetEndOfWeek(DateTimeFormatInfo)

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the last day of the same week, according to the specified formatting information.

extension(DateOnly @this)
{
    public DateOnly GetEndOfWeek(DateTimeFormatInfo dateTimeFormat)
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
dateTimeFormat DateTimeFormatInfo
An object that supplies culture-specific date formatting information.
Returns

DateOnly An instance of DateOnly whose value represents the last day of the week of this, according to dateTimeFormat.

Exceptions
ArgumentNullException
dateTimeFormat is null.
See also

DateOnly.GetStartOfMonth()

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the first day of the same month.

extension(DateOnly @this)
{
    public DateOnly GetStartOfMonth()
}

Parameters

this DateOnly
The instance of DateOnly on which this method is called.

Returns

DateOnly An instance of DateOnly whose value represents the first day of the month of this.

DateOnly.GetStartOfWeek overloads

DateOnly.GetStartOfWeek()

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the first day of the same week, according to the current culture.

extension(DateOnly @this)
{
    public DateOnly GetStartOfWeek()
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
Returns

DateOnly An instance of DateOnly whose value represents the first day of the week of this, according to the current culture.

See also

DateOnly.GetStartOfWeek(DayOfWeek)

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Returns 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.

extension(DateOnly @this)
{
    public DateOnly GetStartOfWeek(DayOfWeek firstDayOfWeek)
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
firstDayOfWeek DayOfWeek
A DayOfWeek value representing the day that starts the week.
Returns

DateOnly An instance of DateOnly whose value represents the first day of the week of this, if weeks are considered starting with firstDayOfWeek.

See also

DateOnly.GetStartOfWeek(CultureInfo)

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the first day of the same week, according to the specified culture.

extension(DateOnly @this)
{
    public DateOnly GetStartOfWeek(CultureInfo culture)
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
culture CultureInfo
An object that supplies culture-specific information.
Returns

DateOnly An instance of DateOnly whose value represents the first day of the week of this, according to culture.

Exceptions
ArgumentNullException
culture is null.
See also

DateOnly.GetStartOfWeek(DateTimeFormatInfo)

Available in: net10.0net11.0(not available in the other target frameworks of the package)

Given a date, returns the first day of the same week, according to the specified formatting information.

extension(DateOnly @this)
{
    public DateOnly GetStartOfWeek(DateTimeFormatInfo dateTimeFormat)
}
Parameters
this DateOnly
The instance of DateOnly on which this method is called.
dateTimeFormat DateTimeFormatInfo
An object that supplies culture-specific date formatting information.
Returns

DateOnly An instance of DateOnly whose value represents the first day of the week of this, according to dateTimeFormat.

Exceptions
ArgumentNullException
dateTimeFormat is null.
See also