import {ZoneOffsetTransition} from '@js-joda/root/packages/core/src/zone/ZoneOffsetTransition.js'
ZoneOffsetTransition
A transition between two offsets caused by a discontinuity in the local time-line.
A transition between two offsets is normally the result of a daylight savings cutover. The discontinuity is normally a gap in spring and an overlap in autumn. ZoneOffsetTransition models the transition between the two offsets.
Gaps occur where there are local date-times that simply do not not exist.
An example would be when the offset changes from +03:00
to +04:00
.
This might be described as 'the clocks will move forward one hour tonight at 1am'.
Overlaps occur where there are local date-times that exist twice.
An example would be when the offset changes from +04:00
to +03:00
.
This might be described as 'the clocks will move back one hour tonight at 2am'.
Static Method Summary
Static Public Methods | ||
public static |
of(transition: LocalDateTime, offsetBefore: ZoneOffset, offsetAfter: ZoneOffset): ZoneOffsetTransition Obtains an instance defining a transition between two offsets. |
Method Summary
Public Methods | ||
public |
compareTo(transition: ZoneOffsetTransition): number Compares this transition to another based on the transition instant. |
|
public |
Gets the local transition date-time, as would be expressed with the 'after' offset. |
|
public |
Gets the local transition date-time, as would be expressed with the 'before' offset. |
|
public |
Gets the duration of the transition. |
|
public |
durationSeconds(): number Gets the duration of the transition in seconds. |
|
public |
equals(other: *): * Checks if this object equals another. |
|
public |
hashCode(): number Returns a suitable hash code. |
|
public |
Gets the transition instant. |
|
public |
isGap(): boolean Does this transition represent a gap in the local time-line. |
|
public |
isOverlap(): boolean Does this transition represent a gap in the local time-line. |
|
public |
isValidOffset(offset: ZoneOffset): boolean Checks if the specified offset is valid during this transition. |
|
public |
Gets the offset after the transition. |
|
public |
Gets the offset before the transition. |
|
public |
toEpochSecond(): number Gets the transition instant as an epoch second. |
|
public |
toString(): string Returns a string describing this object. |
|
public |
validOffsets(): ZoneOffset[] Gets the valid offsets during this transition. |
Static Public Methods
public static of(transition: LocalDateTime, offsetBefore: ZoneOffset, offsetAfter: ZoneOffset): ZoneOffsetTransition source
Obtains an instance defining a transition between two offsets.
Applications should normally obtain an instance from ZoneRules. This factory is only intended for use when creating ZoneRules.
Params:
Name | Type | Attribute | Description |
transition | LocalDateTime | the transition date-time at the transition, which never actually occurs, expressed local to the before offset, not null |
|
offsetBefore | ZoneOffset | the offset before the transition, not null |
|
offsetAfter | ZoneOffset | the offset at and after the transition, not null |
Throw:
* |
IllegalArgumentException if offsetBefore and offsetAfter are equal, or transition.getNano returns non-zero value |
Public Methods
public compareTo(transition: ZoneOffsetTransition): number source
Compares this transition to another based on the transition instant.
This compares the instants of each transition. The offsets are ignored, making this order inconsistent with equals.
Params:
Name | Type | Attribute | Description |
transition | ZoneOffsetTransition | the transition to compare to, not null |
Return:
number | the comparator value, negative if less, positive if greater |
public dateTimeAfter(): LocalDateTime source
Gets the local transition date-time, as would be expressed with the 'after' offset.
This is the first date-time after the discontinuity, when the new offset applies.
The combination of the 'before' date-time and offset represents the same instant as the 'after' date-time and offset.
public dateTimeBefore(): LocalDateTime source
Gets the local transition date-time, as would be expressed with the 'before' offset.
This is the date-time where the discontinuity begins expressed with the 'before' offset. At this instant, the 'after' offset is actually used, therefore the combination of this date-time and the 'before' offset will never occur.
The combination of the 'before' date-time and offset represents the same instant as the 'after' date-time and offset.
public duration(): Duration source
Gets the duration of the transition.
In most cases, the transition duration is one hour, however this is not always the case. The duration will be positive for a gap and negative for an overlap. Time-zones are second-based, so the nanosecond part of the duration will be zero.
public durationSeconds(): number source
Gets the duration of the transition in seconds.
Return:
number | the duration in seconds |
public equals(other: *): * source
Checks if this object equals another.
The entire state of the object is compared.
Params:
Name | Type | Attribute | Description |
other | * | the other object to compare to, null returns false |
Return:
* | true if equal |
public instant(): Instant source
Gets the transition instant.
This is the instant of the discontinuity, which is defined as the first instant that the 'after' offset applies.
The methods getInstant, getDateTimeBefore and getDateTimeAfter all represent the same instant.
public isGap(): boolean source
Does this transition represent a gap in the local time-line.
Gaps occur where there are local date-times that simply do not not exist.
An example would be when the offset changes from +01:00
to +02:00
.
This might be described as 'the clocks will move forward one hour tonight at 1am'.
Return:
boolean | true if this transition is a gap, false if it is an overlap |
public isOverlap(): boolean source
Does this transition represent a gap in the local time-line.
Overlaps occur where there are local date-times that exist twice.
An example would be when the offset changes from +02:00
to +01:00
.
This might be described as 'the clocks will move back one hour tonight at 2am'.
Return:
boolean | true if this transition is an overlap, false if it is a gap |
public isValidOffset(offset: ZoneOffset): boolean source
Checks if the specified offset is valid during this transition.
This checks to see if the given offset will be valid at some point in the transition. A gap will always return false. An overlap will return true if the offset is either the before or after offset.
Params:
Name | Type | Attribute | Description |
offset | ZoneOffset | the offset to check, null returns false |
Return:
boolean | true if the offset is valid during the transition |
public offsetAfter(): ZoneOffset source
Gets the offset after the transition.
This is the offset in use on and after the instant of the transition.
public offsetBefore(): ZoneOffset source
Gets the offset before the transition.
This is the offset in use before the instant of the transition.
public toEpochSecond(): number source
Gets the transition instant as an epoch second.
Return:
number | the transition epoch second |
public toString(): string source
Returns a string describing this object.
Return:
string | a string for debugging, not null |
public validOffsets(): ZoneOffset[] source
Gets the valid offsets during this transition.
A gap will return an empty list, while an overlap will return both offsets.