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
monthintThe month (1-12).
dayintThe 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
Month
The month (1-12).
public int Month { get; }
Property Value
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
otherMonthDayAn 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 otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
From(DateOnly)
The month and day of the given date, with its year dropped.
public static MonthDay From(DateOnly date)
Parameters
dateDateOnly
Returns
Parse(ReadOnlySpan<char>)
Reads the --MM-DD form.
public static MonthDay Parse(ReadOnlySpan<char> s)
Parameters
sReadOnlySpan<char>
Returns
Exceptions
- FormatException
sis 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
sReadOnlySpan<char>providerIFormatProvider
Returns
Exceptions
- FormatException
sis not a valid month and day.
Parse(string)
Reads the --MM-DD form.
public static MonthDay Parse(string s)
Parameters
sstring
Returns
Exceptions
- ArgumentNullException
sis null.- FormatException
sis 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
sstringproviderIFormatProvider
Returns
Exceptions
- ArgumentNullException
sis null.- FormatException
sis not a valid month and day.
ToString()
The value in the --MM-DD form.
public override string ToString()
Returns
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
formatstringformatProviderIFormatProvider
Returns
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
utf8DestinationSpan<byte>bytesWrittenintformatReadOnlySpan<char>providerIFormatProvider
Returns
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
destinationSpan<char>charsWrittenintformatReadOnlySpan<char>providerIFormatProvider
Returns
TryParse(ReadOnlySpan<char>, out MonthDay)
Reads the --MM-DD form, without throwing.
public static bool TryParse(ReadOnlySpan<char> s, out MonthDay result)
Parameters
sReadOnlySpan<char>resultMonthDay
Returns
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
sReadOnlySpan<char>providerIFormatProviderresultMonthDay
Returns
TryParse(string?, out MonthDay)
Reads the --MM-DD form, without throwing.
public static bool TryParse(string? s, out MonthDay result)
Parameters
Returns
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
sstringproviderIFormatProviderresultMonthDay
Returns
Operators
operator >(MonthDay, MonthDay)
Compares two values in calendar order.
public static bool operator >(MonthDay left, MonthDay right)
Parameters
Returns
operator >=(MonthDay, MonthDay)
Compares two values in calendar order.
public static bool operator >=(MonthDay left, MonthDay right)
Parameters
Returns
operator <(MonthDay, MonthDay)
Compares two values in calendar order.
public static bool operator <(MonthDay left, MonthDay right)
Parameters
Returns
operator <=(MonthDay, MonthDay)
Compares two values in calendar order.
public static bool operator <=(MonthDay left, MonthDay right)