Struct ZonedDateTime
A date and time in a time zone, as ZonedDateTimes() draws it: the wall-clock time, the zone, and what the generator's ZoneSource says that wall clock means there. .NET has no such type of its own: a DateTimeOffset keeps the offset but not the zone, and cannot say that a wall-clock time was skipped or repeated.
public readonly record struct ZonedDateTime : IEquatable<ZonedDateTime>
- Implements
- Inherited Members
Constructors
ZonedDateTime(DateTime, TimeSpan, TimeZoneInfo, DateTimeOffset, WallTimeKind)
A zoned date-time from its parts, which are taken as given: nothing checks them against zone.
public ZonedDateTime(DateTime localDateTime, TimeSpan offset, TimeZoneInfo zone, DateTimeOffset instant, WallTimeKind kind)
Parameters
localDateTimeDateTimeThe wall-clock time; its Kind is ignored.
offsetTimeSpanThe UTC offset in force.
zoneTimeZoneInfoThe time zone.
instantDateTimeOffsetThe instant the wall-clock time means.
kindWallTimeKindWhat the wall-clock time is in the zone.
Properties
Instant
The instant, in UTC: the one LocalDateTime names, the one Kind picks of the two a repeated time names, or for a skipped time the wall-clock time read with the offset in force before the clocks changed.
public DateTimeOffset Instant { get; }
Property Value
Kind
Whether the wall clock showed LocalDateTime once, twice or never.
public WallTimeKind Kind { get; }
Property Value
LocalDateTime
The wall-clock time in Zone, of Unspecified.
public DateTime LocalDateTime { get; }
Property Value
Offset
The UTC offset in force at Instant. It need not be a whole number of minutes: a zone's offset before standard time usually is not.
public TimeSpan Offset { get; }
Property Value
Zone
The time zone.
public TimeZoneInfo Zone { get; }
Property Value
Methods
ToDateTimeOffset()
Instant at Offset, with the offset's seconds dropped because a DateTimeOffset holds whole minutes only.
public DateTimeOffset ToDateTimeOffset()
Returns
Exceptions
- ArgumentOutOfRangeException
The result lies outside the years 1 to 9999.
ToString()
The engine's text for the value, such as 2024-03-10T01:30:00-05:00[America/New_York].
public override string ToString()