Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct NodaTime.​YearMonth

Assembly: NodaTime

Implemented Interfaces

A year and month in a particular calendar. This is effectively <see cref="T:NodaTime.LocalDate" /> without the day-of-month component.

Remarks

<para> Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons fail with <see cref="T:System.ArgumentException" />; attempting to compare values in different calendars almost always indicates a bug in the calling code. </para>

Properties

Calendar
Gets the calendar system associated with this year/month.
public int
Year
Gets the year of this year/month.
Remarks This returns the "absolute year", so, for the ISO calendar, a value of 0 means 1 BC, for example.
public int
Month
Gets the month of this year/month within the year.
public int
YearOfEra
Gets the year of this value within the era.
public Era
Era
Gets the era of this year/month.

Methods

public DateInterval
ToDateInterval​()
Returns a <see cref="T:NodaTime.DateInterval" /> covering the month represented by this value.
Returns A <see cref="T:NodaTime.DateInterval" /> covering the month represented by this value.
public YearMonth
PlusMonths​(int months)
Returns a <see cref="T:NodaTime.YearMonth" /> object which is the result of adding the specified number of months to this object.
Returns The resulting <see cref="T:NodaTime.YearMonth" /> after adding the specified number of months.
months The number of months to add to this object.
public LocalDate
OnDayOfMonth​(int day)
Returns a <see cref="T:NodaTime.LocalDate" /> with the year/month of this value, and the given day of month.
Returns The result of combining this year and month with <paramref name="day" /> .
day The day within the month.
public int
CompareTo​(YearMonth other)
Indicates whether this year/month is earlier, later or the same as another one. See the type documentation for a description of ordering semantics.
Returns A value less than zero if this year/month is earlier than <paramref name="other" /> ; zero if this year/month is the same as <paramref name="other" /> ; a value greater than zero if this date is later than <paramref name="other" /> .
other The other year/month to compare this one with
public int
GetHashCode​()
Returns a hash code for this year/month. See the type documentation for a description of equality semantics.
Returns A hash code for this value.
public bool
Equals​(object obj)
Compares two <see cref="T:NodaTime.YearMonth" /> values for equality. See the type documentation for a description of equality semantics.
Returns True if the given value is another year/month equal to this one; false otherwise.
obj The object to compare this year/month with.
public bool
Equals​(YearMonth other)
Compares two <see cref="T:NodaTime.YearMonth" /> values for equality. See the type documentation for a description of ordering semantics.
Returns True if the given value is another year/month equal to this one; false otherwise.
other The value to compare this year/month with.
public string
ToString​(string patternText, System.​IFormatProvider formatProvider)
Formats the value of the current instance using the specified pattern.
Returns A <see cref="T:System.String" /> containing the value of the current instance in the specified format.
patternText The <see cref="T:System.String" /> specifying the pattern to use, or null to use the ISO format pattern ("g").
formatProvider The <see cref="T:System.IFormatProvider" /> to use when formatting the value, or null to use the current thread's culture to obtain a format provider.
Remarks Unlike most <see cref="T:System.IFormattable" /> implementations, a <paramref name="patternText" /> of null with the current thread's culture does not yield the same result as the parameterless <see cref="M:NodaTime.YearMonth.ToString" /> overload, for backward-compatibility reasons. (It uses the ISO format, which is culture-insensitive.)
public string
ToString​()
Returns a <see cref="T:System.String" /> that represents this instance.
Returns The value of the current instance in the culture-specific default format pattern ("G"), using the current thread's culture to obtain a format provider.
AddSchema​(System.​Xml.​Schema.​XmlSchemaSet xmlSchemaSet)
Adds the XML schema type describing the structure of the <see cref="T:NodaTime.YearMonth" /> XML serialization to the given <paramref name="xmlSchemaSet" /> .
Returns The qualified name of the schema type that was added to the <paramref name="xmlSchemaSet" /> .
xmlSchemaSet The XML schema set provided by <see cref="T:System.Xml.Serialization.XmlSchemaExporter" /> .
protected void
Finalize​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object