Struct LocalDate
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
public struct LocalDate : IEquatable<LocalDate>, IComparable<LocalDate>, IComparable, IFormattable
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Constructors
LocalDate(Era, Int32, Int32, Int32)
Declaration
public LocalDate(Era era, int yearOfEra, int month, int day)
Parameters
Type | Name | Description |
---|---|---|
Era | era | The era within which to create a date. Must be a valid era within the ISO calendar. |
Int32 | yearOfEra | The year of era. |
Int32 | month | The month of year. |
Int32 | day | The day of month. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date. |
LocalDate(Era, Int32, Int32, Int32, CalendarSystem)
Declaration
public LocalDate(Era era, int yearOfEra, int month, int day, CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
Era | era | The era within which to create a date. Must be a valid era within the specified calendar. |
Int32 | yearOfEra | The year of era. |
Int32 | month | The month of year. |
Int32 | day | The day of month. |
CalendarSystem | calendar | Calendar system in which to create the date. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date. |
ArgumentNullException | calendar is null. |
LocalDate(Int32, Int32, Int32)
Declaration
public LocalDate(int year, int month, int day)
Parameters
Type | Name | Description |
---|---|---|
Int32 | year | The year. This is the "absolute year", so a value of 0 means 1 BC, for example. |
Int32 | month | The month of year. |
Int32 | day | The day of month. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date. |
LocalDate(Int32, Int32, Int32, CalendarSystem)
Declaration
public LocalDate(int year, int month, int day, CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
Int32 | year | The year. This is the "absolute year", so, for the ISO calendar, a value of 0 means 1 BC, for example. |
Int32 | month | The month of year. |
Int32 | day | The day of month. |
CalendarSystem | calendar | Calendar system in which to create the date. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date. |
ArgumentNullException | calendar is null. |
Properties
Calendar
Declaration
public CalendarSystem Calendar { get; }
Property Value
Type | Description |
---|---|
CalendarSystem |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Day
Declaration
public int Day { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
DayOfWeek
Declaration
public int DayOfWeek { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
See Also
DayOfYear
Declaration
public int DayOfYear { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Era
Declaration
public Era Era { get; }
Property Value
Type | Description |
---|---|
Era |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
IsoDayOfWeek
Declaration
public IsoDayOfWeek IsoDayOfWeek { get; }
Property Value
Type | Description |
---|---|
IsoDayOfWeek |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The underlying calendar doesn't use ISO days of the week. |
See Also
Month
Declaration
public int Month { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
WeekOfWeekYear
Declaration
public int WeekOfWeekYear { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
WeekYear
Declaration
public int WeekYear { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
The WeekYear is the year that matches with the WeekOfWeekYear field. In the standard ISO8601 week algorithm, the first week of the year is that in which at least 4 days are in the year. As a result of this definition, day 1 of the first week may be in the previous year. The WeekYear allows you to query the effective year for that day.
For example, January 1st 2011 was a Saturday, so only two days of that week (Saturday and Sunday) were in 2011. Therefore January 1st is part of week 52 of WeekYear 2010. Conversely, December 31st 2012 is a Monday, so is part of week 1 of WeekYear 2013.
Year
Declaration
public int Year { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
YearOfCentury
Declaration
public int YearOfCentury { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
YearOfEra
Declaration
public int YearOfEra { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Methods
Add(LocalDate, Period)
operator+()
.
Declaration
public static LocalDate Add(LocalDate date, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | date | The date to add the period to |
Period | period | The period to add. Must not contain any (non-zero) time units. |
Returns
Type | Description |
---|---|
LocalDate | The sum of the given date and period |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
AtMidnight()
Declaration
public LocalDateTime AtMidnight()
Returns
Type | Description |
---|---|
LocalDateTime | The LocalDateTime representing midnight on tthis local date, in the same calendar system. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
CompareTo(LocalDate)
Declaration
public int CompareTo(LocalDate other)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | other | The other date to compare this one with |
Returns
Type | Description |
---|---|
Int32 | A value less than zero if this date is earlier than other ;
zero if this date is the same as other ; a value greater than zero if this date is
later than other . |
Remarks
Equals(LocalDate)
Declaration
public bool Equals(LocalDate other)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | other | The value to compare this date with. |
Returns
Type | Description |
---|---|
Boolean | True if the given value is another local date equal to this one; false otherwise. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare this date with. |
Returns
Type | Description |
---|---|
Boolean | True if the given value is another local date equal to this one; false otherwise. |
Overrides
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
FromWeekYearWeekAndDay(Int32, Int32, IsoDayOfWeek)
Declaration
public static LocalDate FromWeekYearWeekAndDay(int weekYear, int weekOfWeekYear, IsoDayOfWeek dayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
Int32 | weekYear | ISO-8601 week year of value to return |
Int32 | weekOfWeekYear | ISO-8601 week of week year of value to return |
IsoDayOfWeek | dayOfWeek | ISO-8601 day of week to return |
Returns
Type | Description |
---|---|
LocalDate | The date corresponding to the given week year / week of week year / day of week. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this local date. |
Overrides
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Minus(Period)
operator-()
.
Declaration
public LocalDate Minus(Period period)
Parameters
Type | Name | Description |
---|---|---|
Period | period | The period to subtract. Must not contain any (non-zero) time units. |
Returns
Type | Description |
---|---|
LocalDate | The result of subtracting the given period from this date. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Next(IsoDayOfWeek)
Declaration
public LocalDate Next(IsoDayOfWeek targetDayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
IsoDayOfWeek | targetDayOfWeek | The ISO day of the week to return the next date of. |
Returns
Type | Description |
---|---|
LocalDate | The next LocalDate falling on the specified day of the week. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The underlying calendar doesn't use ISO days of the week. |
ArgumentOutOfRangeException | targetDayOfWeek is not a valid day of the
week (Monday to Sunday). |
Plus(Period)
operator+()
.
Declaration
public LocalDate Plus(Period period)
Parameters
Type | Name | Description |
---|---|---|
Period | period | The period to add. Must not contain any (non-zero) time units. |
Returns
Type | Description |
---|---|
LocalDate | The sum of this date and the given period |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
PlusDays(Int32)
Declaration
public LocalDate PlusDays(int days)
Parameters
Type | Name | Description |
---|---|---|
Int32 | days | The number of days to add |
Returns
Type | Description |
---|---|
LocalDate | The current value plus the given number of days. |
Remarks
This method does not try to maintain the month or year of the current value, so adding 3 days to a value of January 30th will result in a value of February 2nd.
PlusMonths(Int32)
Declaration
public LocalDate PlusMonths(int months)
Parameters
Type | Name | Description |
---|---|---|
Int32 | months | The number of months to add |
Returns
Type | Description |
---|---|
LocalDate | The current date plus the given number of months |
Remarks
This method does not try to maintain the year of the current value, so adding four months to a value in October will result in a value in the following February.
If the resulting date is invalid, the day of month is reduced to find a valid value. For example, adding one month to January 30th 2011 will return February 28th 2011; subtracting one month from March 30th 2011 will return February 28th 2011.
PlusWeeks(Int32)
Declaration
public LocalDate PlusWeeks(int weeks)
Parameters
Type | Name | Description |
---|---|---|
Int32 | weeks | The number of weeks to add |
Returns
Type | Description |
---|---|
LocalDate | The current value plus the given number of weeks. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
PlusYears(Int32)
Declaration
public LocalDate PlusYears(int years)
Parameters
Type | Name | Description |
---|---|---|
Int32 | years | The number of years to add |
Returns
Type | Description |
---|---|
LocalDate | The current value plus the given number of years. |
Remarks
Previous(IsoDayOfWeek)
Declaration
public LocalDate Previous(IsoDayOfWeek targetDayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
IsoDayOfWeek | targetDayOfWeek | The ISO day of the week to return the previous date of. |
Returns
Type | Description |
---|---|
LocalDate | The previous LocalDate falling on the specified day of the week. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The underlying calendar doesn't use ISO days of the week. |
ArgumentOutOfRangeException | targetDayOfWeek is not a valid day of the
week (Monday to Sunday). |
Subtract(LocalDate, Period)
operator-()
.
Declaration
public static LocalDate Subtract(LocalDate date, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | date | The date to subtract the period from |
Period | period | The period to subtract. Must not contain any (non-zero) time units. |
Returns
Type | Description |
---|---|
LocalDate | The result of subtracting the given period from the date. |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The value of the current instance in the standard format pattern, using the current thread's culture to obtain a format provider. |
Overrides
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
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. |
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
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
WithCalendar(CalendarSystem)
Declaration
public LocalDate WithCalendar(CalendarSystem calendarSystem)
Parameters
Type | Name | Description |
---|---|---|
CalendarSystem | calendarSystem | The calendar system to convert this local date to. |
Returns
Type | Description |
---|---|
LocalDate | The converted LocalDate |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | calendarSystem is null. |
Operators
Addition(LocalDate, LocalTime)
Declaration
public static LocalDateTime operator +(LocalDate date, LocalTime time)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | date | The date to add the time to |
LocalTime | time | The time to add |
Returns
Type | Description |
---|---|
LocalDateTime | The sum of the given date and time |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Addition(LocalDate, Period)
Declaration
public static LocalDate operator +(LocalDate date, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | date | The date to add the period to |
Period | period | The period to add. Must not contain any (non-zero) time units. |
Returns
Type | Description |
---|---|
LocalDate | The sum of the given date and period |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Equality(LocalDate, LocalDate)
Declaration
public static bool operator ==(LocalDate lhs, LocalDate rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | lhs | The first value to compare |
LocalDate | rhs | The second value to compare |
Returns
Type | Description |
---|---|
Boolean | True if the two dates are the same and in the same calendar; false otherwise |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
GreaterThan(LocalDate, LocalDate)
Declaration
public static bool operator>(LocalDate lhs, LocalDate rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | lhs | First operand of the comparison |
LocalDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is strictly later than rhs , false otherwise. |
Remarks
GreaterThanOrEqual(LocalDate, LocalDate)
Declaration
public static bool operator >=(LocalDate lhs, LocalDate rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | lhs | First operand of the comparison |
LocalDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is later than or equal to rhs , false otherwise. |
Remarks
Inequality(LocalDate, LocalDate)
Declaration
public static bool operator !=(LocalDate lhs, LocalDate rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | lhs | The first value to compare |
LocalDate | 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
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
LessThan(LocalDate, LocalDate)
Declaration
public static bool operator <(LocalDate lhs, LocalDate rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | lhs | First operand of the comparison |
LocalDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is strictly earlier than rhs , false otherwise. |
Remarks
LessThanOrEqual(LocalDate, LocalDate)
Declaration
public static bool operator <=(LocalDate lhs, LocalDate rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | lhs | First operand of the comparison |
LocalDate | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
Boolean | true if the lhs is earlier than or equal to rhs , false otherwise. |
Remarks
Subtraction(LocalDate, Period)
Declaration
public static LocalDate operator -(LocalDate date, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | date | The date to subtract the period from |
Period | period | The period to subtract. Must not contain any (non-zero) time units. |
Returns
Type | Description |
---|---|
LocalDate | The result of subtracting the given period from the date |
Remarks
Comparisons of dates can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDate) method) such that all operators other than Inequality(LocalDate, LocalDate) will return false if asked to compare two values in different calendar systems.
However, the CompareTo(LocalDate) method (implementing IComparable<T>) is calendar-insensitive; it compares the two dates historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.
It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.
Explicit Interface Implementations
IComparable.CompareTo(Object)
Declaration
int IComparable.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 LocalDate with another one; see CompareTo(LocalDate) for general details.
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 LocalDate. |