Struct AnnualDate
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.
Since 2.0.x
Availability net45, netstandard1.3
Inherited Members
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public struct AnnualDate : IEquatable<AnnualDate>, IComparable<AnnualDate>
Remarks
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)
Constructs an instance for the given month and day in the ISO calendar.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public AnnualDate(int month, int day)
Parameters
Type | Name | Description |
---|---|---|
Int32 | month | The month of year. |
Int32 | day | The day of month. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date. (February 29th is considered valid.) |
Properties
Day
Gets the day of month.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public int Day { get; }
Property Value
Type | Description |
---|---|
Int32 | The day of month. |
Month
Gets the month of year.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public int Month { get; }
Property Value
Type | Description |
---|---|
Int32 | The month of year. |
Methods
CompareTo(AnnualDate)
Indicates whether this annual date is earlier, later or the same as another one.
Since 2.0.x
Availability net45, netstandard1.3
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 . |
Equals(AnnualDate)
Compares this annual date with the specified one for equality,
by checking whether the two values represent the same annual date - the same month and day.
Since 2.0.x
Availability net45, netstandard1.3
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 |
Equals(Object)
Compares this annual date with the specified reference. An annual date is
only equal to another annual date with the same month and day values.
Since 2.0.x
Availability net45, netstandard1.3
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
System.ValueType.Equals(System.Object)
GetHashCode()
Returns a hash code for this annual date.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this annual date. |
Overrides
System.ValueType.GetHashCode()
InYear(Int32)
Returns this annual date in a particular year, as a LocalDate.
Since 2.0.x
Availability net45, netstandard1.3
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)
IsValidYear(Int32)
Checks whether the specified year forms a valid date with the month/day in this
value, without any truncation. This will always return
true
except
for values representing February 29th, where the specified year is a non leap year.
Since 2.0.x
Availability net45, netstandard1.3
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. |
ToString()
Returns a System.String that represents this instance.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The value of the current instance, in the form MM-dd. |
Overrides
System.ValueType.ToString()
Operators
Equality(AnnualDate, AnnualDate)
Compares two AnnualDate values for equality.
Since 2.0.x
Availability net45, netstandard1.3
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 |
GreaterThan(AnnualDate, AnnualDate)
Compares two annual dates to see if the left one is strictly later than the right
one.
Since 2.0.x
Availability net45, netstandard1.3
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. |
GreaterThanOrEqual(AnnualDate, AnnualDate)
Compares two annual dates to see if the left one is later than or equal to the right
one.
Since 2.0.x
Availability net45, netstandard1.3
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. |
Inequality(AnnualDate, AnnualDate)
Compares two AnnualDate values for inequality.
Since 2.0.x
Availability net45, netstandard1.3
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 |
LessThan(AnnualDate, AnnualDate)
Compares two annual dates to see if the left one is strictly earlier than the right
one.
Since 2.0.x
Availability net45, netstandard1.3
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. |
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of rhs is not the same
as the calendar of lhs . |
LessThanOrEqual(AnnualDate, AnnualDate)
Compares two annual dates to see if the left one is earlier than or equal to the right
one.
Since 2.0.x
Availability net45, netstandard1.3
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. |
Implements
System.IEquatable<T>
System.IComparable<T>