A Temporal.PlainTime object is an Object that contains integers corresponding to a particular hour, minute,
second, millisecond, microsecond, and nanosecond.
Properties of the Temporal.PlainTime Constructor
The value of the [[Prototype]] internal slot of the Temporal.PlainTime constructor is the intrinsic object
%Function.prototype%.
The Temporal.PlainTime constructor has the following properties:
Temporal.PlainTime.prototype
The initial value of `Temporal.PlainTime.prototype` is %Temporal.PlainTime.prototype%.
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
Temporal.PlainTime.from ( _item_ [ , _options_ ] )
This function performs the following steps when called:
1. Return ? ToTemporalTime(_item_, _options_).
Temporal.PlainTime.compare ( _one_, _two_ )
This function performs the following steps when called:
1. Set _one_ to ? ToTemporalTime(_one_).
1. Set _two_ to ? ToTemporalTime(_two_).
1. Return 𝔽(CompareTimeRecord(_one_.[[Time]], _two_.[[Time]])).
Properties of the Temporal.PlainTime Prototype Object
The Temporal.PlainTime prototype object
- is itself an ordinary object.
- is not a Temporal.PlainTime instance and does not have a [[InitializedTemporalTime]] internal slot.
- has a [[Prototype]] internal slot whose value is %Object.prototype%.
Temporal.PlainTime.prototype.constructor
The initial value of `Temporal.PlainTime.prototype.constructor` is %Temporal.PlainTime%.
Temporal.PlainTime.prototype[ %Symbol.toStringTag% ]
The initial value of the %Symbol.toStringTag% property is the String value *"Temporal.PlainTime"*.
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
get Temporal.PlainTime.prototype.hour
`Temporal.PlainTime.prototype.hour` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return 𝔽(_temporalTime_.[[Time]].[[Hour]]).
get Temporal.PlainTime.prototype.minute
`Temporal.PlainTime.prototype.minute` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return 𝔽(_temporalTime_.[[Time]].[[Minute]]).
get Temporal.PlainTime.prototype.second
`Temporal.PlainTime.prototype.second` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return 𝔽(_temporalTime_.[[Time]].[[Second]]).
get Temporal.PlainTime.prototype.millisecond
`Temporal.PlainTime.prototype.millisecond` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return 𝔽(_temporalTime_.[[Time]].[[Millisecond]]).
get Temporal.PlainTime.prototype.microsecond
`Temporal.PlainTime.prototype.microsecond` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return 𝔽(_temporalTime_.[[Time]].[[Microsecond]]).
get Temporal.PlainTime.prototype.nanosecond
`Temporal.PlainTime.prototype.nanosecond` is an accessor property whose set accessor function is *undefined*.
Its get accessor function performs the following steps:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return 𝔽(_temporalTime_.[[Time]].[[Nanosecond]]).
Temporal.PlainTime.prototype.add ( _temporalDurationLike_ )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return ? AddDurationToTime(~add~, _temporalTime_, _temporalDurationLike_).
Temporal.PlainTime.prototype.subtract ( _temporalDurationLike_ )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return ? AddDurationToTime(~subtract~, _temporalTime_, _temporalDurationLike_).
Temporal.PlainTime.prototype.with ( _temporalTimeLike_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. If ? IsPartialTemporalObject(_temporalTimeLike_) is *false*, throw a *TypeError* exception.
1. Let _partialTime_ be ? ToTemporalTimeRecord(_temporalTimeLike_, ~partial~).
1. If _partialTime_.[[Hour]] is not *undefined*, then
1. Let _hour_ be _partialTime_.[[Hour]].
1. Else,
1. Let _hour_ be _temporalTime_.[[Time]].[[Hour]].
1. If _partialTime_.[[Minute]] is not *undefined*, then
1. Let _minute_ be _partialTime_.[[Minute]].
1. Else,
1. Let _minute_ be _temporalTime_.[[Time]].[[Minute]].
1. If _partialTime_.[[Second]] is not *undefined*, then
1. Let _second_ be _partialTime_.[[Second]].
1. Else,
1. Let _second_ be _temporalTime_.[[Time]].[[Second]].
1. If _partialTime_.[[Millisecond]] is not *undefined*, then
1. Let _millisecond_ be _partialTime_.[[Millisecond]].
1. Else,
1. Let _millisecond_ be _temporalTime_.[[Time]].[[Millisecond]].
1. If _partialTime_.[[Microsecond]] is not *undefined*, then
1. Let _microsecond_ be _partialTime_.[[Microsecond]].
1. Else,
1. Let _microsecond_ be _temporalTime_.[[Time]].[[Microsecond]].
1. If _partialTime_.[[Nanosecond]] is not *undefined*, then
1. Let _nanosecond_ be _partialTime_.[[Nanosecond]].
1. Else,
1. Let _nanosecond_ be _temporalTime_.[[Time]].[[Nanosecond]].
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. Let _overflow_ be ? GetTemporalOverflowOption(_resolvedOptions_).
1. Let _result_ be ? RegulateTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _overflow_).
1. Return ! CreateTemporalTime(_result_).
Temporal.PlainTime.prototype.until ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return ? DifferenceTemporalPlainTime(~until~, _temporalTime_, _other_, _options_).
Temporal.PlainTime.prototype.since ( _other_ [ , _options_ ] )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return ? DifferenceTemporalPlainTime(~since~, _temporalTime_, _other_, _options_).
Temporal.PlainTime.prototype.round ( _roundTo_ )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. If _roundTo_ is *undefined*, then
1. Throw a *TypeError* exception.
1. If _roundTo_ is a String, then
1. Let _paramString_ be _roundTo_.
1. Set _roundTo_ to OrdinaryObjectCreate(*null*).
1. Perform ! CreateDataPropertyOrThrow(_roundTo_, *"smallestUnit"*, _paramString_).
1. Else,
1. Set _roundTo_ to ? GetOptionsObject(_roundTo_).
1. NOTE: The following steps read options and perform independent validation in alphabetical order (GetRoundingIncrementOption reads *"roundingIncrement"* and GetRoundingModeOption reads *"roundingMode"*).
1. Let _roundingIncrement_ be ? GetRoundingIncrementOption(_roundTo_).
1. Let _roundingMode_ be ? GetRoundingModeOption(_roundTo_, ~half-expand~).
1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_roundTo_, *"smallestUnit"*, ~time~, ~required~).
1. Let _maximum_ be MaximumTemporalDurationRoundingIncrement(_smallestUnit_).
1. Assert: _maximum_ is not ~unset~.
1. Perform ? ValidateTemporalRoundingIncrement(_roundingIncrement_, _maximum_, *false*).
1. Let _result_ be RoundTime(_temporalTime_.[[Time]], _roundingIncrement_, _smallestUnit_, _roundingMode_).
1. Return ! CreateTemporalTime(_result_).
Temporal.PlainTime.prototype.equals ( _other_ )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Set _other_ to ? ToTemporalTime(_other_).
1. If CompareTimeRecord(_temporalTime_.[[Time]], _other_.[[Time]]) = 0, return *true*.
1. Return *false*.
Temporal.PlainTime.prototype.toString ( [ _options_ ] )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Let _resolvedOptions_ be ? GetOptionsObject(_options_).
1. NOTE: The following steps read options and perform independent validation in alphabetical order (GetTemporalFractionalSecondDigitsOption reads *"fractionalSecondDigits"* and GetRoundingModeOption reads *"roundingMode"*).
1. Let _digits_ be ? GetTemporalFractionalSecondDigitsOption(_resolvedOptions_).
1. Let _roundingMode_ be ? GetRoundingModeOption(_resolvedOptions_, ~trunc~).
1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_resolvedOptions_, *"smallestUnit"*, ~time~, ~unset~).
1. If _smallestUnit_ is ~hour~, throw a *RangeError* exception.
1. Let _precision_ be ToSecondsStringPrecisionRecord(_smallestUnit_, _digits_).
1. Let _roundResult_ be RoundTime(_temporalTime_.[[Time]], _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_).
1. Return TimeRecordToString(_roundResult_, _precision_.[[Precision]]).
Temporal.PlainTime.prototype.toLocaleString ( [ _locales_ [ , _options_ ] ] )
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification.
If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used.
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return TimeRecordToString(_temporalTime_.[[Time]], ~auto~).
Temporal.PlainTime.prototype.toJSON ( )
This method performs the following steps when called:
1. Let _temporalTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalTime_, [[InitializedTemporalTime]]).
1. Return TimeRecordToString(_temporalTime_.[[Time]], ~auto~).
Temporal.PlainTime.prototype.valueOf ( )
This method performs the following steps when called:
1. Throw a *TypeError* exception.
This method always throws, because in the absence of `valueOf()`, expressions with arithmetic operators such as `plainTime1 > plainTime2` would fall back to being equivalent to `plainTime1.toString() > plainTime2.toString()`.
Lexicographical comparison of serialized strings might not seem obviously wrong, because the result would sometimes be correct.
Implementations are encouraged to phrase the error message to point users to `Temporal.PlainTime.compare()`, `Temporal.PlainTime.prototype.equals()`, and/or `Temporal.PlainTime.prototype.toString()`.