Struct AnnualDate
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
[TypeConverter(typeof(AnnualDateTypeConverter))]
public struct AnnualDate : IEquatable<AnnualDate>, IComparable<AnnualDate>, IComparable, IFormattable, IXmlSerializable
Remarks
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.
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.
Constructors
AnnualDate(Int32, Int32)
Declaration
public AnnualDate(int month, int day)
Parameters
Type | Name | Description |
---|---|---|
Int32 | month | The month of year. |
Int32 | day | The day of month. |
Remarks
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.
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.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date. (February 29th is considered valid.) |
Properties
Day
Declaration
public int Day { get; }
Property Value
Type | Description |
---|---|
Int32 | The day of month. |
Remarks
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.
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.
Month
Declaration
public int Month { get; }
Property Value
Type | Description |
---|---|
Int32 | The month of year. |
Remarks
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.
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.
Methods
AddSchema(XmlSchemaSet)
xmlSchemaSet
.
Declaration
public static XmlQualifiedName AddSchema(XmlSchemaSet xmlSchemaSet)
Parameters
Type | Name | Description |
---|---|---|
XmlSchemaSet | xmlSchemaSet | The XML schema set provided by XmlSchemaExporter. |
Returns
Type | Description |
---|---|
XmlQualifiedName | The qualified name of the schema type that was added to the xmlSchemaSet . |
Remarks
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.
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.
CompareTo(AnnualDate)
Declaration
public int CompareTo(AnnualDate other)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | other | The other annual date to compare this one with |
Returns
Type | Description |
---|---|
Int32 | A value less than zero if this annual date is earlier than other ;
zero if this time is the same as other ; a value greater than zero if this annual date is
later than other . |
Remarks
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.
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.
Sample snippet
using NodaTime;
using System;
var february23rd = new AnnualDate(2, 23);
var august17th = new AnnualDate(8, 17);
var lessThan = february23rd.CompareTo(august17th);
var equal = february23rd.CompareTo(february23rd);
var greaterThan = august17th.CompareTo(february23rd);
Console.WriteLine(lessThan);
Console.WriteLine(equal);
Console.WriteLine(greaterThan);
Output:
-1
0
1
CompareTo(Object)
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare this value with. |
Returns
Type | Description |
---|---|
Int32 | The result of comparing this AnnualDate with another one.
If obj is null, this method returns a value greater than 0.
|
Remarks
Exceptions
Type | Condition |
---|---|
ArgumentException | obj is non-null but does not refer to an instance of AnnualDate |
Equals(AnnualDate)
Declaration
public bool Equals(AnnualDate other)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | other | The other annual date to compare this one with |
Returns
Type | Description |
---|---|
Boolean | True if the specified annual date is equal to this one; false otherwise |
Remarks
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.
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.
Sample snippet
using NodaTime;
using System;
var february23rd = new AnnualDate(2, 23);
var august17th = new AnnualDate(8, 17);
var unequal = february23rd.Equals(august17th);
var equal = february23rd.Equals(february23rd);
Console.WriteLine(unequal);
Console.WriteLine(equal);
Output:
False
True
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare this one with |
Returns
Type | Description |
---|---|
Boolean | True if the specified value is an annual date which is equal to this one; false otherwise |
Overrides
Remarks
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.
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.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this annual date. |
Overrides
Remarks
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.
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.
InYear(Int32)
Declaration
public LocalDate InYear(int year)
Parameters
Type | Name | Description |
---|---|---|
Int32 | year | The year component of the required date. |
Returns
Type | Description |
---|---|
LocalDate | A date in the given year, suitable for this annual date. |
Remarks
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 IsValidYear(Int32)
Sample snippet
using NodaTime;
using System;
var annualDate = new AnnualDate(3, 12);
var localDate = annualDate.InYear(2013);
Console.WriteLine(localDate);
Output:
Tuesday, 12 March 2013
IsValidYear(Int32)
true
except
for values representing February 29th, where the specified year is a non leap year.
Declaration
public bool IsValidYear(int year)
Parameters
Type | Name | Description |
---|---|---|
Int32 | year | The year to test for validity |
Returns
Type | Description |
---|---|
Boolean | true if the current value occurs within the given year;
false otherwise. |
Remarks
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.
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.
Sample snippet
using NodaTime;
using System;
var leapDay = new AnnualDate(2, 29);
var leapYear = leapDay.IsValidYear(2020);
var nonLeapYear = leapDay.IsValidYear(2018);
Console.WriteLine(leapYear);
Console.WriteLine(nonLeapYear);
Output:
True
False
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The value of the current instance in the default format pattern ("G"). |
Overrides
Remarks
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.
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.
ToString(String, IFormatProvider)
Declaration
public string ToString(string patternText, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
String | patternText | The String specifying the pattern to use, or null to use the default format pattern ("G"). |
IFormatProvider | formatProvider | The IFormatProvider to use when formatting the value, or null to use the current thread's culture to obtain a format provider. |
Returns
Type | Description |
---|---|
String | A String containing the value of the current instance in the specified format. |
Remarks
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.
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.
Operators
Equality(AnnualDate, AnnualDate)
Declaration
public static bool operator ==(AnnualDate lhs, AnnualDate rhs)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | lhs | The first value to compare |
AnnualDate | rhs | The second value to compare |
Returns
Type | Description |
---|---|
Boolean | True if the two dates are the same; false otherwise |
Remarks
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.
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.
GreaterThan(AnnualDate, AnnualDate)
Declaration
public static bool operator>(AnnualDate lhs, AnnualDate rhs)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | lhs | First operand of the comparison |
AnnualDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is strictly later than rhs , false otherwise. |
Remarks
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.
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.
GreaterThanOrEqual(AnnualDate, AnnualDate)
Declaration
public static bool operator >=(AnnualDate lhs, AnnualDate rhs)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | lhs | First operand of the comparison |
AnnualDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is later than or equal to rhs , false otherwise. |
Remarks
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.
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.
Inequality(AnnualDate, AnnualDate)
Declaration
public static bool operator !=(AnnualDate lhs, AnnualDate rhs)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | lhs | The first value to compare |
AnnualDate | rhs | The second value to compare |
Returns
Type | Description |
---|---|
Boolean | False if the two dates are the same and in the same calendar; true otherwise |
Remarks
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.
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.
LessThan(AnnualDate, AnnualDate)
Declaration
public static bool operator <(AnnualDate lhs, AnnualDate rhs)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | lhs | First operand of the comparison |
AnnualDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is strictly earlier than rhs , false otherwise. |
Remarks
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.
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.
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of rhs is not the same
as the calendar of lhs . |
LessThanOrEqual(AnnualDate, AnnualDate)
Declaration
public static bool operator <=(AnnualDate lhs, AnnualDate rhs)
Parameters
Type | Name | Description |
---|---|---|
AnnualDate | lhs | First operand of the comparison |
AnnualDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is earlier than or equal to rhs , false otherwise. |
Remarks
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.
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.
Explicit Interface Implementations
IXmlSerializable.GetSchema()
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type | Description |
---|---|
XmlSchema |
Remarks
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.
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.
IXmlSerializable.ReadXml(XmlReader)
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type | Name | Description |
---|---|---|
XmlReader | reader |
Remarks
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.
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.
IXmlSerializable.WriteXml(XmlWriter)
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
XmlWriter | writer |
Remarks
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.
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.