Table of Contents

Struct MonthDay

Namespace
Quartz
Assembly
Quartz.dll

A day of the year with no year attached — "December 25th", every year.

public readonly record struct MonthDay : IComparable<MonthDay>, ISpanParsable<MonthDay>, IParsable<MonthDay>, ISpanFormattable, IFormattable, IUtf8SpanFormattable, IEquatable<MonthDay>
Implements
Inherited Members

Remarks

This is the value AnnualCalendar excludes: the same date every year. A DateOnly always carries a year, so a set of them either lies about the year or fails its own membership test; this type says exactly what is stored.

February 29th is a valid value — in years without one, no day matches it.

Its text form is the ISO 8601 spelling of a recurring month-day, --MM-DD: always seven characters, and the only form Parse(string, IFormatProvider?) reads. There is nothing to vary, so the format string and the format provider every formatting and parsing member takes are ignored — they are there because the BCL interfaces ask for them.

Constructors

MonthDay(int, int)

Initializes a new MonthDay.

public MonthDay(int month, int day)

Parameters

month int

The month (1-12).

day int

The day of the month (1 through the month's length; February counts 29).

Exceptions

ArgumentOutOfRangeException

The pair is not a valid day of any year.

Properties

Day

The day of the month (1-31).

public int Day { get; }

Property Value

int

Month

The month (1-12).

public int Month { get; }

Property Value

int

Methods

CompareTo(MonthDay)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(MonthDay other)

Parameters

other MonthDay

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

From(DateOnly)

The month and day of the given date, with its year dropped.

public static MonthDay From(DateOnly date)

Parameters

date DateOnly

Returns

MonthDay

Parse(ReadOnlySpan<char>)

Reads the --MM-DD form.

public static MonthDay Parse(ReadOnlySpan<char> s)

Parameters

s ReadOnlySpan<char>

Returns

MonthDay

Exceptions

FormatException

s is not a valid month and day.

Parse(ReadOnlySpan<char>, IFormatProvider?)

Reads the --MM-DD form. provider is ignored: the form is fixed.

public static MonthDay Parse(ReadOnlySpan<char> s, IFormatProvider? provider)

Parameters

s ReadOnlySpan<char>
provider IFormatProvider

Returns

MonthDay

Exceptions

FormatException

s is not a valid month and day.

Parse(string)

Reads the --MM-DD form.

public static MonthDay Parse(string s)

Parameters

s string

Returns

MonthDay

Exceptions

ArgumentNullException

s is null.

FormatException

s is not a valid month and day.

Parse(string, IFormatProvider?)

Reads the --MM-DD form. provider is ignored: the form is fixed.

public static MonthDay Parse(string s, IFormatProvider? provider)

Parameters

s string
provider IFormatProvider

Returns

MonthDay

Exceptions

ArgumentNullException

s is null.

FormatException

s is not a valid month and day.

ToString()

The value in the --MM-DD form.

public override string ToString()

Returns

string

ToString(string?, IFormatProvider?)

The value in the --MM-DD form. format and formatProvider are ignored: the form is fixed.

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string
formatProvider IFormatProvider

Returns

string

TryFormat(Span<byte>, out int, ReadOnlySpan<char>, IFormatProvider?)

Writes the --MM-DD form as UTF-8. format and provider are ignored: the form is fixed, ASCII, and always seven bytes.

public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)

Parameters

utf8Destination Span<byte>
bytesWritten int
format ReadOnlySpan<char>
provider IFormatProvider

Returns

bool

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Writes the --MM-DD form. format and provider are ignored: the form is fixed, and always seven characters.

public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)

Parameters

destination Span<char>
charsWritten int
format ReadOnlySpan<char>
provider IFormatProvider

Returns

bool

TryParse(ReadOnlySpan<char>, out MonthDay)

Reads the --MM-DD form, without throwing.

public static bool TryParse(ReadOnlySpan<char> s, out MonthDay result)

Parameters

s ReadOnlySpan<char>
result MonthDay

Returns

bool

TryParse(ReadOnlySpan<char>, IFormatProvider?, out MonthDay)

Reads the --MM-DD form, without throwing. provider is ignored: the form is fixed.

public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out MonthDay result)

Parameters

s ReadOnlySpan<char>
provider IFormatProvider
result MonthDay

Returns

bool

TryParse(string?, out MonthDay)

Reads the --MM-DD form, without throwing.

public static bool TryParse(string? s, out MonthDay result)

Parameters

s string
result MonthDay

Returns

bool

TryParse(string?, IFormatProvider?, out MonthDay)

Reads the --MM-DD form, without throwing. provider is ignored: the form is fixed.

public static bool TryParse(string? s, IFormatProvider? provider, out MonthDay result)

Parameters

s string
provider IFormatProvider
result MonthDay

Returns

bool

Operators

operator >(MonthDay, MonthDay)

Compares two values in calendar order.

public static bool operator >(MonthDay left, MonthDay right)

Parameters

left MonthDay
right MonthDay

Returns

bool

operator >=(MonthDay, MonthDay)

Compares two values in calendar order.

public static bool operator >=(MonthDay left, MonthDay right)

Parameters

left MonthDay
right MonthDay

Returns

bool

operator <(MonthDay, MonthDay)

Compares two values in calendar order.

public static bool operator <(MonthDay left, MonthDay right)

Parameters

left MonthDay
right MonthDay

Returns

bool

operator <=(MonthDay, MonthDay)

Compares two values in calendar order.

public static bool operator <=(MonthDay left, MonthDay right)

Parameters

left MonthDay
right MonthDay

Returns

bool