Noda Time
ZonedDateTime Structure
NamespacesNodaTimeZonedDateTime
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>
Public Structure ZonedDateTime _
	Implements IEquatable(Of ZonedDateTime), IComparable(Of ZonedDateTime)
public value class ZonedDateTime : IEquatable<ZonedDateTime>, 
	IComparable<ZonedDateTime>
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.

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.

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.

Finalize()()()()
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
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()()()().)
GetType()()()()
Gets the Type of the current instance.
(Inherited from Object.)
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.

MemberwiseClone()()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
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.

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()()()()
Converts this date and time to text according to the default formatting for the culture.
(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.

Currently there is no real text handling support for this type.

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) Version: 1.0.0.0 (1.0.1)