Struct LocalDate
LocalDate is an immutable struct representing a date within the calendar,
with no reference to a particular time zone or time of day.
Since 1.4.x
Availability net45, netstandard1.3
Implements
IComparable
IFormattable
IXmlSerializable
ISerializable
Inherited Members
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Assembly: NodaTime.dll
Syntax
[Serializable]
public struct LocalDate : IEquatable<LocalDate>, IComparable<LocalDate>, IComparable, IFormattable, IXmlSerializable, ISerializable
Constructors
LocalDate(Era, Int32, Int32, Int32)
Constructs an instance for the given era, year of era, month and day in the ISO calendar.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The parameters do not form a valid date. |
ArgumentNullException |
era is null. |
LocalDate(Era, Int32, Int32, Int32, CalendarSystem)
Constructs an instance for the given era, year of era, month and day in the specified calendar.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The parameters do not form a valid date. |
ArgumentNullException |
era or calendar is null |
LocalDate(Int32, Int32, Int32)
Constructs an instance for the given year, month and day in the ISO calendar.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Sample snippet
using NodaTime;
using System;
using System.Globalization;
LocalDate date = new LocalDate(2010, 6, 16);
Console.WriteLine(date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
Console.WriteLine(date.Year);
Console.WriteLine(date.Month);
Console.WriteLine(date.Day);
Output:
2010-06-16
2010
6
16
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The parameters do not form a valid date. |
LocalDate(Int32, Int32, Int32, CalendarSystem)
Constructs an instance for the given year, month and day in the specified calendar.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Sample snippet
using NodaTime;
using System;
LocalDate date = new LocalDate(2010, 6, 16, CalendarSystem.Iso);
Console.WriteLine(date);
Output:
Wednesday, 16 June 2010
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The parameters do not form a valid date. |
ArgumentNullException |
calendar is null. |
Properties
Calendar
Gets the calendar system associated with this local date.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public CalendarSystem Calendar { get; }
Property Value
Type |
Description |
CalendarSystem |
The calendar system associated with this local date. (The value returned is never null.) |
Day
Gets the day of this local date within the month.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
Property Value
Type |
Description |
Int32 |
The day of this local date within the month. |
DayOfWeek
Gets the week day of this local date expressed as an
IsoDayOfWeek value.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public IsoDayOfWeek DayOfWeek { get; }
Property Value
Type |
Description |
IsoDayOfWeek |
The week day of this local date expressed as an IsoDayOfWeek . |
DayOfYear
Gets the day of this local date within the year.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public int DayOfYear { get; }
Property Value
Type |
Description |
Int32 |
The day of this local date within the year. |
Era
Gets the era of this local date.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
Property Value
Type |
Description |
Era |
The era of this local date. (The value returned is never null.) |
MaxIsoValue
The maximum (latest) date representable in the ISO calendar system.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate MaxIsoValue { get; }
Property Value
MinIsoValue
The minimum (earliest) date representable in the ISO calendar system.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate MinIsoValue { get; }
Property Value
Month
Gets the month of this local date within the year.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public int Month { get; }
Property Value
Type |
Description |
Int32 |
The month of this local date within the year. |
Year
Gets the year of this local date.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
Property Value
Type |
Description |
Int32 |
The year of this local date. |
YearOfEra
Gets the year of this local date within the era.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public int YearOfEra { get; }
Property Value
Type |
Description |
Int32 |
The year of this local date within the era. |
Methods
Add(LocalDate, Period)
Adds the specified period to the date.
Fields are added in descending order of significance (years first, then months, and so on).
Friendly alternative to operator+()
.
Since 1.4.x
Availability net45, netstandard1.3
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 |
Exceptions
Type |
Condition |
ArgumentNullException |
period is null. |
At(LocalTime)
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public LocalDateTime At(LocalTime time)
Parameters
Type |
Name |
Description |
LocalTime |
time |
The time to combine with this date. |
Returns
Sample snippet
using NodaTime;
using System;
LocalDate date = new LocalDate(2010, 6, 16);
LocalTime time = new LocalTime(16, 20);
LocalDateTime dateTime = date.At(time);
Console.WriteLine(dateTime);
Output:
06/16/2010 16:20:00
AtMidnight()
Gets a
LocalDateTime at midnight on the date represented by this local date.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public LocalDateTime AtMidnight()
Returns
AtStartOfDayInZone(DateTimeZone)
Resolves this local date into a
ZonedDateTime in the given time zone representing the
start of this date in the given zone.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public ZonedDateTime AtStartOfDayInZone(DateTimeZone zone)
Parameters
Type |
Name |
Description |
DateTimeZone |
zone |
The time zone to map this local date into |
Returns
Exceptions
Type |
Condition |
SkippedTimeException |
The entire day was skipped due to a very large time zone transition.
(This is extremely rare.) |
ArgumentNullException |
zone is null. |
CompareTo(LocalDate)
Indicates whether this date is earlier, later or the same as another one.
Since 1.4.x
Availability net45, netstandard1.3
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 . |
Exceptions
Type |
Condition |
ArgumentException |
The calendar system of other is not the
same as the calendar system of this value. |
Deconstruct(out Int32, out Int32, out Int32)
Deconstructs the current instance into its components.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public void Deconstruct(out int year, out int month, out int day)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year component of the date. |
Int32 |
month |
The month component of the date. |
Int32 |
day |
The day component of the date. |
Deconstruct(out Int32, out Int32, out Int32, out CalendarSystem)
Deconstructs the current instance into its components.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public void Deconstruct(out int year, out int month, out int day, out CalendarSystem calendar)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year component of the date. |
Int32 |
month |
The month component of the date. |
Int32 |
day |
The day component of the date. |
CalendarSystem |
calendar |
The CalendarSystem associated with the date. |
Equals(LocalDate)
Compares two
LocalDate values for equality. This requires
that the dates be the same, within the same calendar.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Equals(Object)
Compares two
LocalDate values for equality. This requires
that the dates be the same, within the same calendar.
Since 1.4.x
Availability net45, netstandard1.3
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
System.ValueType.Equals(System.Object)
FromDateTime(DateTime)
Converts a System.DateTime of any kind to a LocalDate in the ISO calendar, ignoring the time of day.
This does not perform any time zone conversions, so a DateTime with a System.DateTime.Kind of
System.DateTimeKind.Utc will still represent the same year/month/day - it won't be converted into the local system time.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate FromDateTime(DateTime dateTime)
Parameters
Type |
Name |
Description |
DateTime |
dateTime |
Value to convert into a Noda Time local date |
Returns
Type |
Description |
LocalDate |
A new LocalDate with the same values as the specified DateTime . |
FromDateTime(DateTime, CalendarSystem)
Converts a System.DateTime of any kind to a LocalDate in the specified calendar, ignoring the time of day.
This does not perform any time zone conversions, so a DateTime with a System.DateTime.Kind of
System.DateTimeKind.Utc will still represent the same year/month/day - it won't be converted into the local system time.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate FromDateTime(DateTime dateTime, CalendarSystem calendar)
Parameters
Type |
Name |
Description |
DateTime |
dateTime |
Value to convert into a Noda Time local date |
CalendarSystem |
calendar |
The calendar system to convert into |
Returns
Type |
Description |
LocalDate |
A new LocalDate with the same values as the specified DateTime . |
Exceptions
Type |
Condition |
ArgumentNullException |
calendar is null. |
FromWeekYearWeekAndDay(Int32, Int32, IsoDayOfWeek)
Returns the local date corresponding to the given "week year", "week of week year", and "day of week"
in the ISO calendar system, using the ISO week-year rules.
Since 1.4.x
Availability net45, netstandard1.3
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. |
FromYearMonthWeekAndDay(Int32, Int32, Int32, IsoDayOfWeek)
Returns the local date corresponding to a particular occurrence of a day-of-week
within a year and month. For example, this method can be used to ask for "the third Monday in April 2012".
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate FromYearMonthWeekAndDay(int year, int month, int occurrence, IsoDayOfWeek dayOfWeek)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year of the value to return. |
Int32 |
month |
The month of the value to return. |
Int32 |
occurrence |
The occurrence of the value to return, which must be in the range [1, 5]. The value 5 can
be used to always return the last occurrence of the specified day-of-week, even if there are only 4
occurrences of that day-of-week in the month. |
IsoDayOfWeek |
dayOfWeek |
The day-of-week of the value to return. |
Returns
Type |
Description |
LocalDate |
The date corresponding to the given year and month, on the given occurrence of the
given day of week. |
Remarks
GetHashCode()
Returns a hash code for this local date.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public override int GetHashCode()
Returns
Type |
Description |
Int32 |
A hash code for this local date. |
Overrides
System.ValueType.GetHashCode()
Max(LocalDate, LocalDate)
Returns the later date of the given two.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate Max(LocalDate x, LocalDate y)
Parameters
Type |
Name |
Description |
LocalDate |
x |
The first date to compare. |
LocalDate |
y |
The second date to compare. |
Returns
Type |
Description |
LocalDate |
The later date of x or y . |
Exceptions
Type |
Condition |
ArgumentException |
The two dates have different calendar systems. |
Min(LocalDate, LocalDate)
Returns the earlier date of the given two.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static LocalDate Min(LocalDate x, LocalDate y)
Parameters
Type |
Name |
Description |
LocalDate |
x |
The first date to compare. |
LocalDate |
y |
The second date to compare. |
Returns
Type |
Description |
LocalDate |
The earlier date of x or y . |
Exceptions
Type |
Condition |
ArgumentException |
The two dates have different calendar systems. |
Minus(LocalDate)
Subtracts the specified date from this date, returning the result as a
Period with units of years, months and days.
Fluent alternative to
operator-()
.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public Period Minus(LocalDate date)
Parameters
Type |
Name |
Description |
LocalDate |
date |
The date to subtract from this |
Returns
Type |
Description |
Period |
The difference between the specified date and this one (The value returned is never null.) |
Minus(Period)
Subtracts the specified period from this date.
Fields are subtracted in descending order of significance (years first, then months, and so on).
Fluent alternative to operator-()
.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentNullException |
period is null. |
Next(IsoDayOfWeek)
Returns the next
LocalDate falling on the specified
IsoDayOfWeek.
This is a strict "next" - if this date on already falls on the target
day of the week, the returned value will be a week later.
Since 1.4.x
Availability net45, netstandard1.3
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
Exceptions
Type |
Condition |
System.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)
Adds the specified period to this date.
Fields are added in descending order of significance (years first, then months, and so on).
Fluent alternative to operator+()
.
Since 1.4.x
Availability net45, netstandard1.3
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 |
Exceptions
Type |
Condition |
ArgumentNullException |
period is null. |
PlusDays(Int32)
Returns a new LocalDate representing the current value with the given number of days added.
Since 1.4.x
Availability net45, netstandard1.3
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. |
PlusMonths(Int32)
Returns a new LocalDate representing the current value with the given number of months added.
Since 1.4.x
Availability net45, netstandard1.3
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 |
PlusWeeks(Int32)
Returns a new LocalDate representing the current value with the given number of weeks added.
Since 1.4.x
Availability net45, netstandard1.3
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. |
PlusYears(Int32)
Returns a new LocalDate representing the current value with the given number of years added.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Previous(IsoDayOfWeek)
Returns the previous
LocalDate falling on the specified
IsoDayOfWeek.
This is a strict "previous" - if this date on already falls on the target
day of the week, the returned value will be a week earlier.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
System.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, LocalDate)
Subtracts one date from another, returning the result as a
Period with units of years, months and days.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static Period Subtract(LocalDate lhs, LocalDate rhs)
Parameters
Type |
Name |
Description |
LocalDate |
lhs |
The date to subtract from |
LocalDate |
rhs |
The date to subtract |
Returns
Type |
Description |
Period |
The result of subtracting one date from another. (The value returned is never null.) |
Subtract(LocalDate, Period)
Subtracts the specified period from the date.
Fields are subtracted in descending order of significance (years first, then months, and so on).
Friendly alternative to operator-()
.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentNullException |
period is null. |
ToDateTimeUnspecified()
Constructs a System.DateTime from this value which has a System.DateTime.Kind
of System.DateTimeKind.Unspecified. The result is midnight on the day represented
by this value.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public DateTime ToDateTimeUnspecified()
Returns
Type |
Description |
DateTime |
A System.DateTime value for the same date and time as this value. |
ToString()
Returns a System.String that represents this instance.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public override string ToString()
Returns
Type |
Description |
String |
The value of the current instance in the default format pattern ("D"), using the current thread's
culture to obtain a format provider.
|
Overrides
System.ValueType.ToString()
Formats the value of the current instance using the specified pattern.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public string ToString(string patternText, IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
String |
patternText |
The System.String specifying the pattern to use,
or null to use the default format pattern ("D").
|
IFormatProvider |
formatProvider |
The System.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 System.String containing the value of the current instance in the specified format.
|
With(Func<LocalDate, LocalDate>)
Returns this date, with the given adjuster applied to it.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public LocalDate With(Func<LocalDate, LocalDate> adjuster)
Parameters
Returns
Type |
Description |
LocalDate |
The adjusted date. |
Exceptions
Type |
Condition |
ArgumentNullException |
adjuster is null. |
WithCalendar(CalendarSystem)
Creates a new LocalDate representing the same physical date, but in a different calendar.
The returned LocalDate is likely to have different field values to this one.
For example, January 1st 1970 in the Gregorian calendar was December 19th 1969 in the Julian calendar.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public LocalDate WithCalendar(CalendarSystem calendar)
Parameters
Type |
Name |
Description |
CalendarSystem |
calendar |
The calendar system to convert this local date to. |
Returns
Type |
Description |
LocalDate |
The converted LocalDate |
Exceptions
Type |
Condition |
ArgumentNullException |
calendar is null. |
WithOffset(Offset)
Returns an
OffsetDate for this local date with the given offset.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetDate WithOffset(Offset offset)
Parameters
Type |
Name |
Description |
Offset |
offset |
The offset to apply. |
Returns
Type |
Description |
OffsetDate |
The result of this date offset by the given amount. |
Operators
Addition(LocalDate, LocalTime)
Since 1.4.x
Availability net45, netstandard1.3
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 |
Sample snippet
using NodaTime;
using System;
LocalDate date = new LocalDate(2010, 6, 16);
LocalTime time = new LocalTime(16, 20);
LocalDateTime dateTime = date + time;
Console.WriteLine(dateTime);
Output:
06/16/2010 16:20:00
Addition(LocalDate, Period)
Adds the specified period to the date.
Fields are added in descending order of significance (years first, then months, and so on).
Since 1.4.x
Availability net45, netstandard1.3
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 |
Exceptions
Type |
Condition |
ArgumentNullException |
period is null. |
Equality(LocalDate, LocalDate)
Compares two
LocalDate values for equality. This requires
that the dates be the same, within the same calendar.
Since 1.4.x
Availability net45, netstandard1.3
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 |
GreaterThan(LocalDate, LocalDate)
Compares two dates to see if the left one is strictly later than the right
one.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentException |
The calendar system of rhs is not the same
as the calendar of lhs . |
GreaterThanOrEqual(LocalDate, LocalDate)
Compares two dates to see if the left one is later than or equal to the right
one.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentException |
The calendar system of rhs is not the same
as the calendar of lhs . |
Inequality(LocalDate, LocalDate)
Compares two
LocalDate values for inequality.
Since 1.4.x
Availability net45, netstandard1.3
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 |
LessThan(LocalDate, LocalDate)
Compares two dates to see if the left one is strictly earlier than the right
one.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentException |
The calendar system of rhs is not the same
as the calendar of lhs . |
LessThanOrEqual(LocalDate, LocalDate)
Compares two dates to see if the left one is earlier than or equal to the right
one.
Since 1.4.x
Availability net45, netstandard1.3
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. |
Exceptions
Type |
Condition |
ArgumentException |
The calendar system of rhs is not the same
as the calendar of lhs . |
Subtraction(LocalDate, LocalDate)
Subtracts one date from another, returning the result as a
Period with units of years, months and days.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static Period operator -(LocalDate lhs, LocalDate rhs)
Parameters
Type |
Name |
Description |
LocalDate |
lhs |
The date to subtract from |
LocalDate |
rhs |
The date to subtract |
Returns
Type |
Description |
Period |
The result of subtracting one date from another. (The value returned is never null.) |
Exceptions
Type |
Condition |
ArgumentException |
lhs and rhs are not in the same calendar system.
|
Subtraction(LocalDate, Period)
Subtracts the specified period from the date.
Fields are subtracted in descending order of significance (years first, then months, and so on).
This is a convenience operator over the
Minus(Period) method.
Since 1.4.x
Availability net45, netstandard1.3
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 |
Exceptions
Type |
Condition |
ArgumentNullException |
period is null. |
Explicit Interface Implementations
IComparable.CompareTo(Object)
Implementation of System.IComparable.CompareTo(System.Object) to compare two LocalDates.
Since 2.3.x
Availability net45, netstandard1.3
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.
|
Exceptions
Type |
Condition |
ArgumentException |
obj is non-null but does not refer to an instance of LocalDate, or refers
to a date in a different calendar system. |
ISerializable.GetObjectData(SerializationInfo, StreamingContext)
Implementation of System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext).
Since 2.3.x
Availability net45
Declaration
[SecurityCritical]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type |
Name |
Description |
SerializationInfo |
info |
The System.Runtime.Serialization.SerializationInfo to populate with data. |
StreamingContext |
context |
The destination for this serialization. |
Exceptions
Type |
Condition |
ArgumentNullException |
info is null. |
IXmlSerializable.GetSchema()
Since 2.3.x
Availability net45, netstandard1.3
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type |
Description |
XmlSchema |
|
IXmlSerializable.ReadXml(XmlReader)
Since 2.3.x
Availability net45, netstandard1.3
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type |
Name |
Description |
XmlReader |
reader |
|
Exceptions
Type |
Condition |
ArgumentNullException |
reader is null. |
IXmlSerializable.WriteXml(XmlWriter)
Since 2.3.x
Availability net45, netstandard1.3
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type |
Name |
Description |
XmlWriter |
writer |
|
Exceptions
Type |
Condition |
ArgumentNullException |
writer is null. |
Implements
System.IEquatable<T>
System.IComparable<T>
System.IComparable
System.IFormattable
System.Xml.Serialization.IXmlSerializable
System.Runtime.Serialization.ISerializable