Struct LocalDateTime
Implements
Inherited Members
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
[TypeConverter(typeof(LocalDateTimeTypeConverter))]
public readonly struct LocalDateTime : IEquatable<LocalDateTime>, IComparable<LocalDateTime>, IComparable, IFormattable, IXmlSerializable
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Constructors
LocalDateTime(int, int, int, int, int, CalendarSystem)
Declaration
public LocalDateTime(int year, int month, int day, int hour, int minute, CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year. This is the "absolute year", so, for the ISO calendar, a value of 0 means 1 BC, for example. |
int | month | The month of year. |
int | day | The day of month. |
int | hour | The hour. |
int | minute | The minute. |
CalendarSystem | calendar | The calendar. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Sample snippet
using NodaTime;
using System;
CalendarSystem calendar = CalendarSystem.Iso;
LocalDateTime dt = new LocalDateTime(2010, 6, 16, 16, 20, calendar);
Console.WriteLine(dt.Minute);
Output:
20
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date/time. |
LocalDateTime(int, int, int, int, int, int, CalendarSystem)
Declaration
public LocalDateTime(int year, int month, int day, int hour, int minute, int second, CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year. This is the "absolute year", so, for the ISO calendar, a value of 0 means 1 BC, for example. |
int | month | The month of year. |
int | day | The day of month. |
int | hour | The hour. |
int | minute | The minute. |
int | second | The second. |
CalendarSystem | calendar | The calendar. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date/time. |
LocalDateTime(int, int, int, int, int, int, int, CalendarSystem)
Declaration
public LocalDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year. This is the "absolute year", so, for the ISO calendar, a value of 0 means 1 BC, for example. |
int | month | The month of year. |
int | day | The day of month. |
int | hour | The hour. |
int | minute | The minute. |
int | second | The second. |
int | millisecond | The millisecond. |
CalendarSystem | calendar | The calendar. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date/time. |
LocalDateTime(int, int, int, int, int, int, int)
Declaration
public LocalDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year. This is the "absolute year", so a value of 0 means 1 BC, for example. |
int | month | The month of year. |
int | day | The day of month. |
int | hour | The hour. |
int | minute | The minute. |
int | second | The second. |
int | millisecond | The millisecond. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date/time. |
LocalDateTime(int, int, int, int, int, int)
Declaration
public LocalDateTime(int year, int month, int day, int hour, int minute, int second)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year. This is the "absolute year", so a value of 0 means 1 BC, for example. |
int | month | The month of year. |
int | day | The day of month. |
int | hour | The hour. |
int | minute | The minute. |
int | second | The second. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date/time. |
LocalDateTime(int, int, int, int, int)
Declaration
public LocalDateTime(int year, int month, int day, int hour, int minute)
Parameters
Type | Name | Description |
---|---|---|
int | year | The year. This is the "absolute year", so a value of 0 means 1 BC, for example. |
int | month | The month of year. |
int | day | The day of month. |
int | hour | The hour. |
int | minute | The minute. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Sample snippet
using NodaTime;
using NodaTime.Text;
using System;
LocalDateTime dt = new LocalDateTime(2010, 6, 16, 16, 20);
Console.WriteLine(LocalDateTimePattern.GeneralIso.Format(dt));
Console.WriteLine(dt.Calendar);
Output:
2010-06-16T16:20:00
ISO
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The parameters do not form a valid date/time. |
Properties
Calendar
Declaration
public CalendarSystem Calendar { get; }
Property Value
Type | Description |
---|---|
CalendarSystem | The calendar system associated with this local date and time. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
ClockHourOfHalfDay
Declaration
public int ClockHourOfHalfDay { get; }
Property Value
Type | Description |
---|---|
int | The hour of the half-day of this local date and time, in the range 1 to 12 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Date
Declaration
public LocalDate Date { get; }
Property Value
Type | Description |
---|---|
LocalDate | The date portion of this local date and time as a LocalDate in the same calendar system as this value. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Day
Declaration
public int Day { get; }
Property Value
Type | Description |
---|---|
int | The day of this local date and time within the month. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
DayOfWeek
Declaration
public IsoDayOfWeek DayOfWeek { get; }
Property Value
Type | Description |
---|---|
IsoDayOfWeek | The week day of this local date and time expressed as an IsoDayOfWeek . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
DayOfYear
Declaration
public int DayOfYear { get; }
Property Value
Type | Description |
---|---|
int | The day of this local date and time within the year. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Era
Declaration
public Era Era { get; }
Property Value
Type | Description |
---|---|
Era | The era of this local date and time. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Hour
Declaration
public int Hour { get; }
Property Value
Type | Description |
---|---|
int | The hour of day of this local date and time, in the range 0 to 23 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
MaxIsoValue
Declaration
public static LocalDateTime MaxIsoValue { get; }
Property Value
Type | Description |
---|---|
LocalDateTime |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Millisecond
Declaration
public int Millisecond { get; }
Property Value
Type | Description |
---|---|
int | The millisecond of this local date and time within the second, in the range 0 to 999 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
MinIsoValue
Declaration
public static LocalDateTime MinIsoValue { get; }
Property Value
Type | Description |
---|---|
LocalDateTime |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Minute
Declaration
public int Minute { get; }
Property Value
Type | Description |
---|---|
int | The minute of this local date and time, in the range 0 to 59 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Month
Declaration
public int Month { get; }
Property Value
Type | Description |
---|---|
int | The month of this local date and time within the year. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
NanosecondOfDay
Declaration
public long NanosecondOfDay { get; }
Property Value
Type | Description |
---|---|
long | The nanosecond of this local date and time within the day, in the range 0 to 86,399,999,999,999 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
NanosecondOfSecond
Declaration
public int NanosecondOfSecond { get; }
Property Value
Type | Description |
---|---|
int | The nanosecond of this local time within the second, in the range 0 to 999,999,999 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Second
Declaration
public int Second { get; }
Property Value
Type | Description |
---|---|
int | The second of this local date and time within the minute, in the range 0 to 59 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
TickOfDay
Declaration
public long TickOfDay { get; }
Property Value
Type | Description |
---|---|
long | The tick of this local date and time within the day, in the range 0 to 863,999,999,999 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
TickOfSecond
Declaration
public int TickOfSecond { get; }
Property Value
Type | Description |
---|---|
int | The tick of this local time within the second, in the range 0 to 9,999,999 inclusive. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
TimeOfDay
Declaration
public LocalTime TimeOfDay { get; }
Property Value
Type | Description |
---|---|
LocalTime | The time portion of this local date and time as a LocalTime . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Year
Declaration
public int Year { get; }
Property Value
Type | Description |
---|---|
int | The year of this local date and time. |
Remarks
YearOfEra
Declaration
public int YearOfEra { get; }
Property Value
Type | Description |
---|---|
int | The year of this local date and time within its era. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Methods
Add(LocalDateTime, Period)
operator+()
.
Declaration
public static LocalDateTime Add(LocalDateTime localDateTime, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | localDateTime | Initial local date and time |
Period | period | Period to add |
Returns
Type | Description |
---|---|
LocalDateTime | The resulting local date and time |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
AddSchema(XmlSchemaSet)
xmlSchemaSet
.
the 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
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
CompareTo(LocalDateTime)
Declaration
public int CompareTo(LocalDateTime other)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | other | The other local date/time to compare with this value. |
Returns
Type | Description |
---|---|
int | A value less than zero if this date/time is earlier than other ;
zero if this date/time is the same as other ; a value greater than zero if this date/time is
later than other . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of other is not the
same as the calendar system of this value. |
Deconstruct(out LocalDate, out LocalTime)
Declaration
public void Deconstruct(out LocalDate date, out LocalTime time)
Parameters
Type | Name | Description |
---|---|---|
LocalDate | date | The date portion of the value. |
LocalTime | time | The time portion of the value. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Equals(LocalDateTime)
Declaration
public bool Equals(LocalDateTime other)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool |
true if the current object is equal to the other parameter; otherwise, false.
|
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Equals(object?)
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The Object to compare with this instance. |
Returns
Type | Description |
---|---|
bool |
true if the specified Object is equal to this instance;
otherwise, false .
|
Overrides
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
FromDateTime(DateTime, CalendarSystem)
Declaration
public static LocalDateTime FromDateTime(DateTime dateTime, CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | Value to convert into a Noda Time local date and time |
CalendarSystem | calendar | The calendar system to convert into |
Returns
Type | Description |
---|---|
LocalDateTime | A new LocalDateTime with the same values as the specified DateTime . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
FromDateTime(DateTime)
Declaration
public static LocalDateTime FromDateTime(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | Value to convert into a Noda Time local date and time |
Returns
Type | Description |
---|---|
LocalDateTime | A new LocalDateTime with the same values as the specified DateTime . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
InUtc()
Declaration
public ZonedDateTime InUtc()
Returns
Type | Description |
---|---|
ZonedDateTime | The result of mapping this local date/time in UTC. |
Remarks
InZone(DateTimeZone, ZoneLocalMappingResolver)
Declaration
public ZonedDateTime InZone(DateTimeZone zone, ZoneLocalMappingResolver resolver)
Parameters
Type | Name | Description |
---|---|---|
DateTimeZone | zone | The time zone to map this local date and time into |
ZoneLocalMappingResolver | resolver | The resolver to apply to the mapping. |
Returns
Type | Description |
---|---|
ZonedDateTime | The result of resolving the mapping. |
Remarks
InZoneLeniently(DateTimeZone)
Declaration
public ZonedDateTime InZoneLeniently(DateTimeZone zone)
Parameters
Type | Name | Description |
---|---|---|
DateTimeZone | zone | The time zone in which to map this local date/time. |
Returns
Type | Description |
---|---|
ZonedDateTime | The result of mapping this local date/time in the given time zone. |
Remarks
Note: The behavior of this method was changed in version 2.0 to fit the most commonly seen real-world usage pattern. Previous versions returned the later instance of ambiguous values, and returned the start of the zone interval after the gap for skipped value. The previous functionality can still be used if desired, by using InZone(DateTimeZone, ZoneLocalMappingResolver) and passing a resolver that combines the ReturnLater and ReturnStartOfIntervalAfter resolvers.
InZoneStrictly(DateTimeZone)
Declaration
public ZonedDateTime InZoneStrictly(DateTimeZone zone)
Parameters
Type | Name | Description |
---|---|---|
DateTimeZone | zone | The time zone in which to map this local date/time. |
Returns
Type | Description |
---|---|
ZonedDateTime | The result of mapping this local date/time in the given time zone. |
Remarks
Exceptions
Type | Condition |
---|---|
SkippedTimeException | This local date/time is skipped in the given time zone. |
AmbiguousTimeException | This local date/time is ambiguous in the given time zone. |
Max(LocalDateTime, LocalDateTime)
Declaration
public static LocalDateTime Max(LocalDateTime x, LocalDateTime y)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | x | The first date/time to compare. |
LocalDateTime | y | The second date/time to compare. |
Returns
Type | Description |
---|---|
LocalDateTime | The later date/time of x or y . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The two date/times have different calendar systems. |
Min(LocalDateTime, LocalDateTime)
Declaration
public static LocalDateTime Min(LocalDateTime x, LocalDateTime y)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | x | The first date/time to compare. |
LocalDateTime | y | The second date/time to compare. |
Returns
Type | Description |
---|---|
LocalDateTime | The earlier date/time of x or y . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The two date/times have different calendar systems. |
Minus(LocalDateTime)
operator-()
.
Declaration
public Period Minus(LocalDateTime localDateTime)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | localDateTime | The date/time to subtract from this |
Returns
Type | Description |
---|---|
Period | The difference between the specified date/time and this one |
Remarks
Minus(Period)
Declaration
public LocalDateTime Minus(Period period)
Parameters
Type | Name | Description |
---|---|---|
Period | period | Period to subtract |
Returns
Type | Description |
---|---|
LocalDateTime | The resulting local date and time |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Next(IsoDayOfWeek)
Declaration
public LocalDateTime Next(IsoDayOfWeek targetDayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
IsoDayOfWeek | targetDayOfWeek | The ISO day of the week to return the next date of. |
Returns
Type | Description |
---|---|
LocalDateTime | The next LocalDateTime falling on the specified day of the week. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
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)
Declaration
public LocalDateTime Plus(Period period)
Parameters
Type | Name | Description |
---|---|---|
Period | period | Period to add |
Returns
Type | Description |
---|---|
LocalDateTime | The resulting local date and time |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusDays(int)
Declaration
public LocalDateTime PlusDays(int days)
Parameters
Type | Name | Description |
---|---|---|
int | days | The number of days to add |
Returns
Type | Description |
---|---|
LocalDateTime | 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 on January 30th will result in a value on February 2nd.
PlusHours(long)
Declaration
public LocalDateTime PlusHours(long hours)
Parameters
Type | Name | Description |
---|---|---|
long | hours | The number of hours to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of hours. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusMilliseconds(long)
Declaration
public LocalDateTime PlusMilliseconds(long milliseconds)
Parameters
Type | Name | Description |
---|---|---|
long | milliseconds | The number of milliseconds to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of milliseconds. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusMinutes(long)
Declaration
public LocalDateTime PlusMinutes(long minutes)
Parameters
Type | Name | Description |
---|---|---|
long | minutes | The number of minutes to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of minutes. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusMonths(int)
Declaration
public LocalDateTime PlusMonths(int months)
Parameters
Type | Name | Description |
---|---|---|
int | months | The number of months to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value 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.
PlusNanoseconds(long)
Declaration
public LocalDateTime PlusNanoseconds(long nanoseconds)
Parameters
Type | Name | Description |
---|---|---|
long | nanoseconds | The number of nanoseconds to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of nanoseconds. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusSeconds(long)
Declaration
public LocalDateTime PlusSeconds(long seconds)
Parameters
Type | Name | Description |
---|---|---|
long | seconds | The number of seconds to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of seconds. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusTicks(long)
Declaration
public LocalDateTime PlusTicks(long ticks)
Parameters
Type | Name | Description |
---|---|---|
long | ticks | The number of ticks to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of ticks. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusWeeks(int)
Declaration
public LocalDateTime PlusWeeks(int weeks)
Parameters
Type | Name | Description |
---|---|---|
int | weeks | The number of weeks to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of weeks. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
PlusYears(int)
Declaration
public LocalDateTime PlusYears(int years)
Parameters
Type | Name | Description |
---|---|---|
int | years | The number of years to add |
Returns
Type | Description |
---|---|
LocalDateTime | The current value plus the given number of years. |
Remarks
Previous(IsoDayOfWeek)
Declaration
public LocalDateTime Previous(IsoDayOfWeek targetDayOfWeek)
Parameters
Type | Name | Description |
---|---|---|
IsoDayOfWeek | targetDayOfWeek | The ISO day of the week to return the previous date of. |
Returns
Type | Description |
---|---|
LocalDateTime | The previous LocalDateTime falling on the specified day of the week. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
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(LocalDateTime, LocalDateTime)
Declaration
public static Period Subtract(LocalDateTime lhs, LocalDateTime rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | lhs | The date/time to subtract from |
LocalDateTime | rhs | The date/time to subtract |
Returns
Type | Description |
---|---|
Period | The result of subtracting one date/time from another. |
Remarks
Subtract(LocalDateTime, Period)
operator-()
.
Declaration
public static LocalDateTime Subtract(LocalDateTime localDateTime, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | localDateTime | Initial local date and time |
Period | period | Period to subtract |
Returns
Type | Description |
---|---|
LocalDateTime | The resulting local date and time |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
ToDateTimeUnspecified()
Declaration
public DateTime ToDateTimeUnspecified()
Returns
Type | Description |
---|---|
DateTime | A DateTime value for the same date and time as this value. |
Remarks
Unspecified is slightly odd - it can be treated as UTC if you use ToLocalTime() or as system local time if you use ToUniversalTime(), but it's the only kind which allows you to construct a DateTimeOffset with an arbitrary offset, which makes it as close to the Noda Time non-system-specific "local" concept as exists in .NET.
If the date and time is not on a tick boundary (the unit of granularity of DateTime) the value will be truncated towards the start of time.
DateTime uses the Gregorian calendar by definition, so the value is implicitly converted to the Gregorian calendar first. The result will be on the same physical day, but the values returned by the Year/Month/Day properties of the DateTime may not match the Year/Month/Day properties of this value.
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The date/time is outside the range of DateTime . |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The value of the current instance in the default format pattern ("G"), using the current thread's culture to obtain a format provider. |
Overrides
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
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
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Sample snippet
using NodaTime;
using System;
using System.Globalization;
LocalDateTime dt = new LocalDateTime(2010, 6, 16, 16, 20);
Console.WriteLine(dt.ToString("uuuu-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture));
Output:
2010-06-16T16:20:00
With(Func<LocalDate, LocalDate>)
Declaration
public LocalDateTime With(Func<LocalDate, LocalDate> adjuster)
Parameters
Type | Name | Description |
---|---|---|
Func<LocalDate, LocalDate> | adjuster | The adjuster to apply. |
Returns
Type | Description |
---|---|
LocalDateTime | The adjusted date/time. |
Remarks
With(Func<LocalTime, LocalTime>)
Declaration
public LocalDateTime With(Func<LocalTime, LocalTime> adjuster)
Parameters
Type | Name | Description |
---|---|---|
Func<LocalTime, LocalTime> | adjuster | The adjuster to apply. |
Returns
Type | Description |
---|---|
LocalDateTime | The adjusted date/time. |
Remarks
WithCalendar(CalendarSystem)
Declaration
public LocalDateTime WithCalendar(CalendarSystem calendar)
Parameters
Type | Name | Description |
---|---|---|
CalendarSystem | calendar | The calendar system to convert this local date to. |
Returns
Type | Description |
---|---|
LocalDateTime | The converted LocalDateTime. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
WithOffset(Offset)
Declaration
public OffsetDateTime WithOffset(Offset offset)
Parameters
Type | Name | Description |
---|---|---|
Offset | offset | The offset to apply. |
Returns
Type | Description |
---|---|
OffsetDateTime | The result of this local date/time offset by the given amount. |
Remarks
Operators
operator +(LocalDateTime, Period)
Declaration
public static LocalDateTime operator +(LocalDateTime localDateTime, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | localDateTime | Initial local date and time |
Period | period | Period to add |
Returns
Type | Description |
---|---|
LocalDateTime | The resulting local date and time |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
operator ==(LocalDateTime, LocalDateTime)
Declaration
public static bool operator ==(LocalDateTime left, LocalDateTime right)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | left | The left hand side of the operator. |
LocalDateTime | right | The right hand side of the operator. |
Returns
Type | Description |
---|---|
bool | true if values are equal to each other, otherwise false . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
operator >(LocalDateTime, LocalDateTime)
Declaration
public static bool operator >(LocalDateTime lhs, LocalDateTime rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | lhs | First operand of the comparison |
LocalDateTime | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
bool | true if the lhs is strictly later than rhs , false otherwise. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of rhs is not the same
as the calendar of lhs . |
operator >=(LocalDateTime, LocalDateTime)
Declaration
public static bool operator >=(LocalDateTime lhs, LocalDateTime rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | lhs | First operand of the comparison |
LocalDateTime | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
bool | true if the lhs is later than or equal to rhs , false otherwise. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of rhs is not the same
as the calendar of lhs . |
operator !=(LocalDateTime, LocalDateTime)
Declaration
public static bool operator !=(LocalDateTime left, LocalDateTime right)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | left | The left hand side of the operator. |
LocalDateTime | right | The right hand side of the operator. |
Returns
Type | Description |
---|---|
bool | true if values are not equal to each other, otherwise false . |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
operator <(LocalDateTime, LocalDateTime)
Declaration
public static bool operator <(LocalDateTime lhs, LocalDateTime rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | lhs | First operand of the comparison |
LocalDateTime | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
bool | true if the lhs is strictly earlier than rhs , false otherwise. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of rhs is not the same
as the calendar of lhs . |
operator <=(LocalDateTime, LocalDateTime)
Declaration
public static bool operator <=(LocalDateTime lhs, LocalDateTime rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | lhs | First operand of the comparison |
LocalDateTime | rhs | Second operand of the comparison |
Returns
Type | Description |
---|---|
bool | true if the lhs is earlier than or equal to rhs , false otherwise. |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.
Exceptions
Type | Condition |
---|---|
ArgumentException | The calendar system of rhs is not the same
as the calendar of lhs . |
operator -(LocalDateTime, LocalDateTime)
Declaration
public static Period operator -(LocalDateTime lhs, LocalDateTime rhs)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | lhs | The date/time to subtract from |
LocalDateTime | rhs | The date/time to subtract |
Returns
Type | Description |
---|---|
Period | The result of subtracting one date/time from another. |
Remarks
operator -(LocalDateTime, Period)
Declaration
public static LocalDateTime operator -(LocalDateTime localDateTime, Period period)
Parameters
Type | Name | Description |
---|---|---|
LocalDateTime | localDateTime | Initial local date and time |
Period | period | Period to subtract |
Returns
Type | Description |
---|---|
LocalDateTime | The resulting local date and time |
Remarks
This type defaults to using the ISO calendar system unless a different calendar system is specified.
Values can freely be compared for equality: a value in a different calendar system is not equal to a value in a different calendar system. However, ordering comparisons (either via the CompareTo(LocalDateTime) method or via operators) fail with ArgumentException; attempting to compare values in different calendars almost always indicates a bug in the calling code.
The default value of this type is 0001-01-01T00:00:00 (midnight on January 1st, 1 C.E.) in the ISO calendar.