Class ZoneInterval
Represents a range of time for which a particular Offset applies.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Inherited Members
Namespace: NodaTime.TimeZones
Assembly: NodaTime.dll
Syntax
public sealed class ZoneInterval : IEquatable<ZoneInterval?>, IEqualityOperators<ZoneInterval, ZoneInterval, bool>
Remarks
Equality is defined component-wise in terms of all properties: the name, the start and end, and the offsets. There is no ordering defined between zone intervals.
Constructors
ZoneInterval(string, Instant?, Instant?, Offset, Offset)
Initializes a new instance of the ZoneInterval class.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public ZoneInterval(string name, Instant? start, Instant? end, Offset wallOffset, Offset savings)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of this offset period (e.g. PST or PDT). |
Instant? | start | The first Instant that the wallOffset applies,
or null to make the zone interval extend to the start of time. |
Instant? | end | The last Instant (exclusive) that the wallOffset applies,
or null to make the zone interval extend to the end of time. |
Offset | wallOffset | The WallOffset from UTC for this period including any daylight savings. |
Offset | savings | The WallOffset daylight savings contribution to the offset. |
Exceptions
Type | Condition |
---|---|
ArgumentException | If . |
Properties
Duration
Gets the duration of this zone interval.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Duration Duration { get; }
Property Value
Type | Description |
---|---|
Duration | The Duration of this zone interval. |
Remarks
This is effectively
End - Start
.Exceptions
Type | Condition |
---|---|
InvalidOperationException | This zone extends to the start or end of time. |
End
Gets the last Instant (exclusive) that the Offset applies.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Instant End { get; }
Property Value
Type | Description |
---|---|
Instant | The last Instant (exclusive) that the Offset applies. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The zone interval extends to the end of time |
HasEnd
Returns
true
if this zone interval has a fixed end point, or false
if it
extends to the end of time.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public bool HasEnd { get; }
Property Value
Type | Description |
---|---|
bool | true if this interval has a fixed end point, or false if it
extends to the end of time. |
HasStart
Returns
true
if this zone interval has a fixed start point, or false
if it
extends to the beginning of time.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public bool HasStart { get; }
Property Value
Type | Description |
---|---|
bool | true if this interval has a fixed start point, or false if it
extends to the beginning of time. |
IsoLocalEnd
Gets the local end time of the interval, as a LocalDateTime
in the ISO calendar.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public LocalDateTime IsoLocalEnd { get; }
Property Value
Type | Description |
---|---|
LocalDateTime | The local end time of the interval in the ISO calendar, with the offset of this zone interval. As the end time is exclusive, by the time this local time is reached, the next interval will be in effect and the local time will usually have changed (e.g. by adding or subtracting an hour). |
Exceptions
Type | Condition |
---|---|
OverflowException | The interval ends too late to represent as a `LocalDateTime`. |
InvalidOperationException | The interval extends to the end of time. |
IsoLocalStart
Gets the local start time of the interval, as a LocalDateTime
in the ISO calendar.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public LocalDateTime IsoLocalStart { get; }
Property Value
Type | Description |
---|---|
LocalDateTime | The local start time of the interval in the ISO calendar, with the offset of this zone interval. |
Exceptions
Type | Condition |
---|---|
OverflowException | The interval starts too early to represent as a `LocalDateTime`. |
InvalidOperationException | The interval extends to the start of time. |
Name
Gets the name of this offset period (e.g. PST or PDT).
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string | The name of this offset period (e.g. PST or PDT). |
Savings
Gets the daylight savings value for this period.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Offset Savings { get; }
Property Value
Type | Description |
---|---|
Offset | The savings value. |
StandardOffset
Gets the standard offset for this period. This is the offset without any daylight savings
contributions.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Offset StandardOffset { get; }
Property Value
Type | Description |
---|---|
Offset | The base Offset. |
Remarks
This is effectively
WallOffset - Savings
.Start
Gets the first Instant that the Offset applies.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Instant Start { get; }
Property Value
Type | Description |
---|---|
Instant | The first Instant that the Offset applies. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The interval extends to the start of time. |
WallOffset
Gets the offset from UTC for this period. This includes any daylight savings value.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public Offset WallOffset { get; }
Property Value
Type | Description |
---|---|
Offset | The offset from UTC for this period. |
Methods
Contains(Instant)
Determines whether this period contains the given Instant in its range.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public bool Contains(Instant instant)
Parameters
Type | Name | Description |
---|---|---|
Instant | instant | The instant to test. |
Returns
Type | Description |
---|---|
bool | true if this period contains the given Instant in its range; otherwise, false . |
Remarks
Usually this is half-open, i.e. the end is exclusive, but an interval with an end point of "the end of time"
is deemed to be inclusive at the end.
Equals(ZoneInterval?)
Indicates whether the current object is equal to another object of the same type.
See the type documentation for a description of equality semantics.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public bool Equals(ZoneInterval? other)
Parameters
Type | Name | Description |
---|---|---|
ZoneInterval | 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. |
Equals(object?)
Determines whether the specified object is equal to the current object.
See the type documentation for a description of equality semantics.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false . |
Overrides
GetHashCode()
Returns a hash code for this zone interval.
See the type documentation for a description of equality semantics.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this zone interval. |
Overrides
ToString()
Returns a string that represents this instance.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents this instance. |
Overrides
Operators
operator ==(ZoneInterval?, ZoneInterval?)
Implements the operator == (equality).
See the type documentation for a description of equality semantics.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static bool operator ==(ZoneInterval? left, ZoneInterval? right)
Parameters
Type | Name | Description |
---|---|---|
ZoneInterval | left | The left hand side of the operator. |
ZoneInterval | right | The right hand side of the operator. |
Returns
Type | Description |
---|---|
bool | true if values are equal to each other, otherwise false . |
operator !=(ZoneInterval?, ZoneInterval?)
Implements the operator != (inequality).
See the type documentation for a description of equality semantics.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static bool operator !=(ZoneInterval? left, ZoneInterval? right)
Parameters
Type | Name | Description |
---|---|---|
ZoneInterval | left | The left hand side of the operator. |
ZoneInterval | right | The right hand side of the operator. |
Returns
Type | Description |
---|---|
bool | true if values are not equal to each other, otherwise false . |