Noda Time
ZonedDateTime Structure
NamespacesNodaTimeZonedDateTime

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

A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants. A ZonedDateTime is global, in that it maps to a single Instant.
Declaration Syntax
C#Visual BasicVisual C++
public struct ZonedDateTime : IEquatable<ZonedDateTime>, 
	IComparable<ZonedDateTime>, IComparable, IXmlSerializable
Public Structure ZonedDateTime _
	Implements IEquatable(Of ZonedDateTime), IComparable(Of ZonedDateTime),  _
	IComparable, IXmlSerializable
public value class ZonedDateTime : IEquatable<ZonedDateTime>, 
	IComparable<ZonedDateTime>, IComparable, IXmlSerializable
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
ZonedDateTime(Instant, DateTimeZone, CalendarSystem)
Initializes a new instance of the ZonedDateTime struct.

ZonedDateTime(Instant, DateTimeZone)
Initializes a new instance of the ZonedDateTime struct in the specified time zone and the ISO calendar.

ZonedDateTime(LocalDateTime, DateTimeZone, Offset)
Initializes a new instance of the ZonedDateTime struct in the specified time zone from a given local time and offset. The offset is validated to be correct as part of initialization. In most cases a local time can only map to a single instant anyway, but the offset is included here for cases where the local time is ambiguous, usually due to daylight saving transitions.

Add(ZonedDateTime, Duration)
Adds a duration to a zoned date and time. Friendly alternative to operator+().

Addition(ZonedDateTime, Duration)
Returns a new ZonedDateTime with the time advanced by the given duration. Note that due to daylight saving time changes this may not advance the local time by the same amount.

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

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

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

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

Date
Gets the local date represented by this zoned date and time. The returned LocalDate will have the same calendar system and return the same values for each of the date-based calendar properties (Year, MonthOfYear and so on), but will not be associated with any particular time zone.

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

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

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

Equality(ZonedDateTime, ZonedDateTime)
Implements the operator ==.

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

Equals(Object)
Indicates whether this instance and a specified object are equal.
(Overrides ValueType.Equals(Object).)
Era
Gets the era for this zoned date and time.

FromDateTimeOffset(DateTimeOffset)
Returns a new ZonedDateTime representing the same instant in time as the given DateTimeOffset. The time zone used will be a fixed time zone, which uses the same offset throughout time.

GetHashCode()()()()
Computes the hash code for this instance.
(Overrides ValueType.GetHashCode()()()().)
GetZoneInterval()()()()
Returns the ZoneInterval containing this value, in the time zone this value refers to.

GreaterThan(ZonedDateTime, ZonedDateTime)
Compares two ZonedDateTime values to see if the left one is strictly later than the right one.

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

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

Inequality(ZonedDateTime, ZonedDateTime)
Implements the operator !=.

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

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

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

LocalDateTime
Gets the local date and time represented by this zoned date and time. The returned LocalDateTime will have the same calendar system and return the same values for each of the calendar properties (Year, MonthOfYear and so on), but will not be associated with any particular time zone.

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

Minus(Duration)
Returns the result of subtracting a duration from this zoned date and time, for a fluent alternative to operator-().

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

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

Offset
Gets the offset of the local representation of this value from UTC.

Plus(Duration)
Returns the result of adding a duration to this zoned date and time, for a fluent alternative to operator+().

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

Subtract(ZonedDateTime, Duration)
Subtracts a duration from a zoned date and time. Friendly alternative to operator-().

Subtraction(ZonedDateTime, Duration)
Returns a new ZonedDateTime with the duration subtracted. Note that due to daylight saving time changes this may not change the local time by the same amount.

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

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

TimeOfDay
Gets the time portion of this zoned date and time. The returned LocalTime will return the same values for each of the time-based properties (Hour, Minute and so on), but will not be associated with any particular time zone.

ToDateTimeOffset()()()()
Constructs a DateTimeOffset value with the same local time and offset from UTC as this value.

ToDateTimeUnspecified()()()()
Constructs a DateTime from this ZonedDateTime which has a Kind of Unspecified and represents the same local time as this value rather than the same instant in time.

ToDateTimeUtc()()()()
Constructs a DateTime from this ZonedDateTime which has a Kind of Utc and represents the same instant of time as this value rather than the same local time.

ToInstant()()()()
Converts this value to the instant it represents on the time line.

ToOffsetDateTime()()()()
Constructs an OffsetDateTime with the same local date and time, and the same offset as this zoned date and time, effectively just "removing" the time zone itself.

ToString()()()()
Currently returns a string representation of this value indicating the local time, offset and time zone separately. The default ToString method of each component is used, which will render the local time and offset in the "general" pattern for the current thread's culture, and simply include the ID for most time zone implementations.
(Overrides ValueType.ToString()()()().)
WeekOfWeekYear
Gets the week within the WeekYear. See WeekYear for more details.

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

WithZone(DateTimeZone)
Creates a new ZonedDateTime representing the same instant in time, in the same calendar but a different time zone.

Year
Gets the year of this zoned date and time.

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

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

Zone
Gets the time zone associated with this value.

Remarks

Although ZonedDateTime includes both local and global concepts, it only supports duration-based - and not calendar-based - arithmetic. This avoids ambiguities and skipped date/time values becoming a problem within a series of calculations; instead, these can be considered just once, at the point of conversion to a ZonedDateTime.

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

However, the CompareTo(ZonedDateTime) method (implementing IComparable<(Of <(<'T>)>)>) is calendar and zone insensitive; it compares the two global instants in terms of when they actually occurred.

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)