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.​AnnualDate
Assembly: NodaTime
Implemented Interfaces
- System.​IEquatable`1
- System.​IComparable`1
- System.​IComparable
- System.​IFormattable
- System.​Xml.​Serialization.​IXmlSerializable
- System.​Numerics.​IComparisonOperators`3 (Inherits: IEqualityOperators<​NodaTime.​AnnualDate, NodaTime.​AnnualDate, bool>)
Represents an annual date (month and day) in the ISO calendar but without a specific year, typically for recurrent events such as birthdays, anniversaries, and deadlines.
Remarks
<para>
Equality and comparison order are defined in the natural way. Two values are equal if they
represent the same month and the same day-of-month. One value is earlier than another if it
has a smaller month, or the same month but an earlier day-of-month.
</para> <para>
In the future, this struct may be expanded to support other calendar systems,
but this does not generalize terribly cleanly, particularly to the Hebrew calendar system
with its leap month.
</para> <para>The default value of this type is January 1st.</para>
Properties
public
int
Month
Gets the month of year.
public
int
Day
Gets the day of month.
Methods
public
LocalDate
InYear​(int year)
Returns this annual date in a particular year, as a <see cref="T:NodaTime.LocalDate" /> .
Returns A date in the given year, suitable for this annual date.
year
The year component of the required date.
Remarks
<para>
If this value represents February 29th, and the specified year is not a leap
year, the returned value will be February 28th of that year. To see whether the
original month and day is valid without truncation in a particular year,
use <see cref="M:NodaTime.AnnualDate.IsValidYear(System.Int32)" /></para>
public
bool
IsValidYear​(int year)
Checks whether the specified year forms a valid date with the month/day in this
value, without any truncation. This will always return <c>true</c> except
for values representing February 29th, where the specified year is a non leap year.
Returns <c>true</c> if the current value occurs within the given year;
<c>false</c> otherwise.
year
The year to test for validity
public
bool
Equals​(object obj)
Compares this annual date with the specified reference.
See the type documentation for a description of equality semantics.
Returns True if the specified value is an annual date which is equal to this one; false otherwise
obj
The object to compare this one with
public
int
GetHashCode​()
Returns a hash code for this annual date.
See the type documentation for a description of equality semantics.
Returns A hash code for this annual date.
public
string
ToString​()
Returns a <see cref="T:System.String" /> that represents this instance.
Returns The value of the current instance in the default format pattern ("G").
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 default 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.
public
bool
Equals​(AnnualDate other)
Compares this annual date with the specified one for equality.
See the type documentation for a description of equality semantics.
Returns True if the specified annual date is equal to this one; false otherwise
other
The other annual date to compare this one with
public
int
CompareTo​(AnnualDate other)
Indicates whether this annual date 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 annual date is earlier than <paramref name="other" /> ;
zero if this time is the same as <paramref name="other" /> ; a value greater than zero if this annual date is
later than <paramref name="other" /> .
other
The other annual date to compare this one with
public
int
CompareTo​(object obj)
Implementation of <see cref="M:System.IComparable.CompareTo(System.Object)" /> to compare two AnnualDates.
See the type documentation for a description of ordering semantics.
Returns The result of comparing this AnnualDate with another one.
If <paramref name="obj" /> is null, this method returns a value greater than 0.
obj
The object to compare this value with.
Remarks
This uses explicit interface implementation to avoid it being called accidentally. The generic implementation should usually be preferred.
AddSchema​(System.​Xml.​Schema.​XmlSchemaSet xmlSchemaSet)
Adds the XML schema type describing the structure of the <see cref="T:NodaTime.AnnualDate" /> 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
protected
object
MemberwiseClone​()
Inherited from object