Noda Time
LocalDateTime Structure
NamespacesNodaTimeLocalDateTime

[This is preliminary documentation and is subject to change.]

A date and time in a particular calendar system. A LocalDateTime value does not represent an instant on the time line, because it has no associated time zone: "November 12th 2009 7pm, ISO calendar" occurred at different instants for different people around the world.
Declaration Syntax
C#Visual BasicVisual C++
public struct LocalDateTime : IEquatable<LocalDateTime>, 
	IComparable<LocalDateTime>, IComparable, IFormattable, IXmlSerializable
Public Structure LocalDateTime _
	Implements IEquatable(Of LocalDateTime), IComparable(Of LocalDateTime),  _
	IComparable, IFormattable, IXmlSerializable
public value class LocalDateTime : IEquatable<LocalDateTime>, 
	IComparable<LocalDateTime>, IComparable, IFormattable, IXmlSerializable
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
LocalDateTime(Int32, Int32, Int32, Int32, Int32)
Initializes a new instance of the LocalDateTime struct using the ISO calendar system.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, CalendarSystem)
Initializes a new instance of the LocalDateTime struct.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, Int32)
Initializes a new instance of the LocalDateTime struct using the ISO calendar system.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, Int32, CalendarSystem)
Initializes a new instance of the LocalDateTime struct.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
Initializes a new instance of the LocalDateTime struct using the ISO calendar system.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, CalendarSystem)
Initializes a new instance of the LocalDateTime struct.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
Initializes a new instance of the LocalDateTime struct.

LocalDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, CalendarSystem)
Initializes a new instance of the LocalDateTime struct.

Add(LocalDateTime, Period)
Add the specified period to the date and time. Friendly alternative to operator+().

Addition(LocalDateTime, Period)
Adds a period to a local date/time. Fields are added in the order provided by the period. This is a convenience operator over the Plus(Period) method.

Calendar
Gets the calendar system associated with this local date and time.

CenturyOfEra
Gets the century within the era of this local date and time.

ClockHourOfHalfDay
Gets the hour of the half-day of this local date and time, in the range 1 to 12 inclusive.

CompareTo(LocalDateTime)
Indicates whether this date/time is earlier, later or the same as another one.

Date
Gets the date portion of this local date and time as a LocalDate in the same calendar system as this value.

Day
Gets the day of this local date and time within the month.

DayOfWeek
Gets the week day of this local date and time as a number.

DayOfYear
Gets the day of this local date and time within the year.

Equality(LocalDateTime, LocalDateTime)
Implements the operator == (equality).

Equals(LocalDateTime)
Indicates whether the current object is equal to another object of the same type.

Equals(Object)
Determines whether the specified Object is equal to this instance.
(Overrides ValueType.Equals(Object).)
Era
Gets the era of this local date and time.

FromDateTime(DateTime)
Converts a DateTime of any kind to a LocalDateTime in the ISO calendar. This does not perform any time zone conversions, so a DateTime with a Kind of Utc will still have the same day/hour/minute etc - it won't be converted into the local system time.

GetHashCode()()()()
Returns a hash code for this instance.
(Overrides ValueType.GetHashCode()()()().)
GreaterThan(LocalDateTime, LocalDateTime)
Compares two LocalDateTime values to see if the left one is strictly later than the right one.

GreaterThanOrEqual(LocalDateTime, LocalDateTime)
Compares two LocalDateTime values to see if the left one is later than or equal to the right one.

Hour
Gets the hour of day of this local date and time, in the range 0 to 23 inclusive.

Inequality(LocalDateTime, LocalDateTime)
Implements the operator != (inequality).

InUtc()()()()
Returns the mapping of this local date/time within Utc.

InZone(DateTimeZone, ZoneLocalMappingResolver)
Resolves this local date and time into a ZonedDateTime in the given time zone, following the given ZoneLocalMappingResolver to handle ambiguity and skipped times.

InZoneLeniently(DateTimeZone)
Returns the mapping of this local date/time within the given DateTimeZone, with "lenient" rules applied such that ambiguous values map to the later of the alternatives, and "skipped" values map to the start of the zone interval after the "gap".

InZoneStrictly(DateTimeZone)
Returns the mapping of this local date/time within the given DateTimeZone, with "strict" rules applied such that an exception is thrown if either the mapping is ambiguous or the time is skipped.

IsoDayOfWeek
Gets the week day of this local date and time expressed as an IsoDayOfWeek value, for calendars which use ISO days of the week.

LessThan(LocalDateTime, LocalDateTime)
Compares two LocalDateTime values to see if the left one is strictly earlier than the right one.

LessThanOrEqual(LocalDateTime, LocalDateTime)
Compares two LocalDateTime values to see if the left one is earlier than or equal to the right one.

Millisecond
Gets the millisecond of this local date and time within the second, in the range 0 to 999 inclusive.

Minus(Period)
Subtracts a period from a local date/time. Fields are subtracted in the order provided by the period. This is a convenience operator over the Minus(Period) method.

Minute
Gets the minute of this local date and time, in the range 0 to 59 inclusive.

Month
Gets the month of this local date and time within the year.

Next(IsoDayOfWeek)
Returns the next LocalDateTime falling on the specified IsoDayOfWeek, at the same time of day as this value. This is a strict "next" - if this value on already falls on the target day of the week, the returned value will be a week later.

Plus(Period)
Adds a period to this local date/time. Fields are added in the order provided by the period.

PlusDays(Int32)
Returns a new LocalDateTime representing the current value with the given number of days added.

PlusHours(Int64)
Returns a new LocalDateTime representing the current value with the given number of hours added.

PlusMilliseconds(Int64)
Returns a new LocalDateTime representing the current value with the given number of milliseconds added.

PlusMinutes(Int64)
Returns a new LocalDateTime representing the current value with the given number of minutes added.

PlusMonths(Int32)
Returns a new LocalDateTime representing the current value with the given number of months added.

PlusSeconds(Int64)
Returns a new LocalDateTime representing the current value with the given number of seconds added.

PlusTicks(Int64)
Returns a new LocalDateTime representing the current value with the given number of ticks added.

PlusWeeks(Int32)
Returns a new LocalDateTime representing the current value with the given number of weeks added.

PlusYears(Int32)
Returns a new LocalDateTime representing the current value with the given number of years added.

Previous(IsoDayOfWeek)
Returns the previous LocalDateTime falling on the specified IsoDayOfWeek, at the same time of day as this value. This is a strict "previous" - if this value on already falls on the target day of the week, the returned value will be a week earlier.

Second
Gets the second of this local date and time within the minute, in the range 0 to 59 inclusive.

Subtract(LocalDateTime, Period)
Subtracts the specified period from the date and time. Friendly alternative to operator-().

Subtraction(LocalDateTime, Period)
Subtracts a period from a local date/time. Fields are subtracted in the order provided by the period. This is a convenience operator over the Minus(Period) method.

TickOfDay
Gets the tick of this local date and time within the day, in the range 0 to 863,999,999,999 inclusive.

TickOfSecond
Gets the tick of this local time within the second, in the range 0 to 9,999,999 inclusive.

TimeOfDay
Gets the time portion of this local date and time as a LocalTime.

ToDateTimeUnspecified()()()()
Constructs a DateTime from this value which has a Kind of Unspecified.

ToString()()()()
Returns a String that represents this instance.
(Overrides ValueType.ToString()()()().)
ToString(String, IFormatProvider)
Formats the value of the current instance using the specified pattern.

WeekOfWeekYear
Gets the week within the WeekYear. See WeekYear for more details.

WeekYear
Gets the "week year" of this local date and time.

WithCalendar(CalendarSystem)
Creates a new LocalDateTime representing the same physical date and time, but in a different calendar. The returned LocalDateTime is likely to have different date field values to this one. For example, January 1st 1970 in the Gregorian calendar was December 19th 1969 in the Julian calendar.

WithOffset(Offset)
Returns an OffsetDateTime for this local date/time with the given offset.

Year
Gets the year of this local date and time.

YearOfCentury
Gets the year of this local date and time within its century.

YearOfEra
Gets the year of this local date and time within its era.

Remarks

This type defaults to using the IsoCalendarSystem unless a different calendar system is specified.

Comparisons of values can be handled in a way which is either calendar-sensitive or calendar-insensitive. Noda Time implements all the operators (and the Equals(LocalDateTime) method) such that all operators other than Inequality(LocalDateTime, LocalDateTime) will return false if asked to compare two values in different calendar systems.

However, the CompareTo(LocalDateTime) method (implementing IComparable<(Of <(<'T>)>)>) is calendar-insensitive; it compares the two values historically in terms of when they actually occurred, as if they're both converted to some "neutral" calendar system first.

It's unclear at the time of this writing whether this is the most appropriate approach, and it may change in future versions. In general, it would be a good idea for users to avoid comparing dates in different calendar systems, and indeed most users are unlikely to ever explicitly consider which calendar system they're working in anyway.

Thread Safety
This type is an immutable value type. See the thread safety section of the user guide for more information.

Assembly: NodaTime (Module: NodaTime.dll) Version: 1.2.0.0 (1.2.0)