Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions spec/annexes.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ <h1>Implementation Dependent Behaviour</h1>
</li>
</ul>
</li>
<li>
In Temporal:
<ul>
<li>The calendrical calculations used for calendars other than *"iso8601"* (<emu-xref href="#sec-calendar-abstract-ops"></emu-xref>)</li>
</ul>
</li>
</ul>
</emu-annex>

Expand Down
443 changes: 348 additions & 95 deletions spec/datetimeformat.html

Large diffs are not rendered by default.

225 changes: 17 additions & 208 deletions spec/durationformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ <h1>Intl.DurationFormat.prototype.resolvedOptions ( )</h1>
</emu-clause>

<emu-clause id="sec-Intl.DurationFormat.prototype.format">
<h1>Intl.DurationFormat.prototype.format ( _duration_ )</h1>
<h1>Intl.DurationFormat.prototype.format ( _durationLike_ )</h1>

<p>When the `format` method is called with an argument _duration_, the following steps are taken:</p>
<p>When the `format` method is called with an argument _durationLike_, the following steps are taken:</p>

<emu-alg>
1. Let _df_ be the *this* value.
1. Perform ? RequireInternalSlot(_df_, [[InitializedDurationFormat]]).
1. Let _record_ be ? ToDurationRecord(_duration_).
1. Let _parts_ be PartitionDurationFormatPattern(_df_, _record_).
1. Let _duration_ be ? ToTemporalDuration(_durationLike_).
1. Let _parts_ be PartitionDurationFormatPattern(_df_, _duration_).
1. Let _result_ be the empty String.
1. For each Record { [[Type]], [[Value]], [[Unit]] } _part_ in _parts_, do
1. Set _result_ to the string-concatenation of _result_ and _part_.[[Value]].
Expand All @@ -325,15 +325,15 @@ <h1>Intl.DurationFormat.prototype.format ( _duration_ )</h1>
</emu-clause>

<emu-clause id="sec-Intl.DurationFormat.prototype.formatToParts">
<h1>Intl.DurationFormat.prototype.formatToParts ( _duration_ )</h1>
<h1>Intl.DurationFormat.prototype.formatToParts ( _durationLike_ )</h1>

<p>When the `formatToParts` method is called with an argument _duration_, the following steps are taken:</p>
<p>When the `formatToParts` method is called with an argument _durationLike_, the following steps are taken:</p>

<emu-alg>
1. Let _df_ be the *this* value.
1. Perform ? RequireInternalSlot(_df_, [[InitializedDurationFormat]]).
1. Let _record_ be ? ToDurationRecord(_duration_).
1. Let _parts_ be PartitionDurationFormatPattern(_df_, _record_).
1. Let _duration_ be ? ToTemporalDuration(_durationLike_).
1. Let _parts_ be PartitionDurationFormatPattern(_df_, _duration_).
1. Let _result_ be ! ArrayCreate(0).
1. Let _n_ be 0.
1. For each Record { [[Type]], [[Value]], [[Unit]] } _part_ in _parts_, do
Expand Down Expand Up @@ -385,197 +385,6 @@ <h1>Properties of Intl.DurationFormat Instances</h1>
<emu-clause id="sec-intl-durationformat-abstracts">
<h1>Abstract Operations for DurationFormat Objects</h1>

<emu-clause id="sec-duration-records">
<h1>Duration Records</h1>
<p>A <dfn variants="Duration Records">Duration Record</dfn> is a Record value used to represent a Duration.</p>
<p>Duration Records have the fields listed in <emu-xref href="#table-duration-record-fields"></emu-xref></p>
<emu-table id="table-duration-record-fields" caption="Duration Record Fields">
<table class="real-table">
<tr>
<th>Field</th>
<th>Meaning</th>
</tr>
<tr>
<td>[[Years]]</td>
<td>
The number of years in the duration.
</td>
</tr>
<tr>
<td>[[Months]]</td>
<td>
The number of months in the duration.
</td>
</tr>
<tr>
<td>[[Weeks]]</td>
<td>
The number of weeks in the duration.
</td>
</tr>
<tr>
<td>[[Days]]</td>
<td>
The number of days in the duration.
</td>
</tr>
<tr>
<td>[[Hours]]</td>
<td>
The number of hours in the duration.
</td>
</tr>
<tr>
<td>[[Minutes]]</td>
<td>
The number of minutes in the duration.
</td>
</tr>
<tr>
<td>[[Seconds]]</td>
<td>
The number of seconds in the duration.
</td>
</tr>
<tr>
<td>[[Milliseconds]]</td>
<td>
The number of milliseconds in the duration.
</td>
</tr>
<tr>
<td>[[Microseconds]]</td>
<td>
The number of microseconds in the duration.
</td>
</tr>
<tr>
<td>[[Nanoseconds]]</td>
<td>
The number of nanoseconds in the duration.
</td>
</tr>
</table>
</emu-table>
</emu-clause>

<emu-clause id="sec-tointegerifintegral" oldids="sec-tointegerwithoutrounding" type="abstract operation">
<h1>
ToIntegerIfIntegral (
_argument_: an ECMAScript language value,
): either a normal completion containing an integer, or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It converts _argument_ to an integer representing its Number value, or throws a *RangeError* when that value is not <emu-xref href="#integral-number">integral</emu-xref>.</dd>
</dl>
<emu-alg>
1. Let _number_ be ? ToNumber(_argument_).
1. If _number_ is not an integral Number, throw a *RangeError* exception.
1. Return ℝ(_number_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-todurationrecord" type="abstract operation">
<h1>
ToDurationRecord (
_input_: an ECMAScript language value,
): either a normal completion containing a Duration Record, or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It converts a given object that represents a Duration into a Duration Record.</dd>
</dl>

<emu-alg>
1. If _input_ is not an Object, then
1. If _input_ is a String, throw a *RangeError* exception.
1. Throw a *TypeError* exception.
1. Let _result_ be a new Duration Record with each field set to 0.
1. Let _days_ be ? Get(_input_, *"days"*).
1. If _days_ is not *undefined*, set _result_.[[Days]] to ? ToIntegerIfIntegral(_days_).
1. Let _hours_ be ? Get(_input_, *"hours"*).
1. If _hours_ is not *undefined*, set _result_.[[Hours]] to ? ToIntegerIfIntegral(_hours_).
1. Let _microseconds_ be ? Get(_input_, *"microseconds"*).
1. If _microseconds_ is not *undefined*, set _result_.[[Microseconds]] to ? ToIntegerIfIntegral(_microseconds_).
1. Let _milliseconds_ be ? Get(_input_, *"milliseconds"*).
1. If _milliseconds_ is not *undefined*, set _result_.[[Milliseconds]] to ? ToIntegerIfIntegral(_milliseconds_).
1. Let _minutes_ be ? Get(_input_, *"minutes"*).
1. If _minutes_ is not *undefined*, set _result_.[[Minutes]] to ? ToIntegerIfIntegral(_minutes_).
1. Let _months_ be ? Get(_input_, *"months"*).
1. If _months_ is not *undefined*, set _result_.[[Months]] to ? ToIntegerIfIntegral(_months_).
1. Let _nanoseconds_ be ? Get(_input_, *"nanoseconds"*).
1. If _nanoseconds_ is not *undefined*, set _result_.[[Nanoseconds]] to ? ToIntegerIfIntegral(_nanoseconds_).
1. Let _seconds_ be ? Get(_input_, *"seconds"*).
1. If _seconds_ is not *undefined*, set _result_.[[Seconds]] to ? ToIntegerIfIntegral(_seconds_).
1. Let _weeks_ be ? Get(_input_, *"weeks"*).
1. If _weeks_ is not *undefined*, set _result_.[[Weeks]] to ? ToIntegerIfIntegral(_weeks_).
1. Let _years_ be ? Get(_input_, *"years"*).
1. If _years_ is not *undefined*, set _result_.[[Years]] to ? ToIntegerIfIntegral(_years_).
1. If _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, and _nanoseconds_ are all *undefined*, throw a *TypeError* exception.
1. If IsValidDuration( _result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]) is *false*, then
1. Throw a *RangeError* exception.
1. Return _result_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-durationsign" type="abstract operation">
<h1>
DurationSign (
_duration_: a Duration Record,
): -1, 0, or 1
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns 1 if the most significant non-zero field in the _duration_ argument is positive, and -1 if the most significant non-zero field is negative. If all of _duration_'s fields are zero, it returns 0.</dd>
</dl>
<emu-alg>
1. For each value _v_ of « _duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]] », do
1. If _v_ &lt; 0, return -1.
1. If _v_ > 0, return 1.
1. Return 0.
</emu-alg>
</emu-clause>

<emu-clause id="sec-isvalidduration" type="abstract operation">
<h1>
IsValidDuration (
_years_: an integer,
_months_: an integer,
_weeks_: an integer,
_days_: an integer,
_hours_: an integer,
_minutes_: an integer,
_seconds_: an integer,
_milliseconds_: an integer,
_microseconds_: an integer,
_nanoseconds_: an integer,
): a Boolean
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns *true* if its arguments form valid input from which to construct a Duration Record, and *false* otherwise.</dd>
</dl>
<emu-alg>
1. Let _sign_ be 0.
1. For each value _v_ of « _years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_ », do
1. If 𝔽(_v_) is not finite, return *false*.
1. If _v_ &lt; 0, then
1. If _sign_ > 0, return *false*.
1. Set _sign_ to -1.
1. Else if _v_ > 0, then
1. If _sign_ &lt; 0, return *false*.
1. Set _sign_ to 1.
1. If abs(_years_) ≥ 2<sup>32</sup>, return *false*.
1. If abs(_months_) ≥ 2<sup>32</sup>, return *false*.
1. If abs(_weeks_) ≥ 2<sup>32</sup>, return *false*.
1. Let _normalizedSeconds_ be _days_ × 86,400 + _hours_ × 3600 + _minutes_ × 60 + _seconds_ + ℝ(𝔽(_milliseconds_)) × 10<sup>-3</sup> + ℝ(𝔽(_microseconds_)) × 10<sup>-6</sup> + ℝ(𝔽(_nanoseconds_)) × 10<sup>-9</sup>.
1. NOTE: The above step cannot be implemented directly using floating-point arithmetic. Multiplying by 10<sup>-3</sup>, 10<sup>-6</sup>, and 10<sup>-9</sup> respectively may be imprecise when _milliseconds_, _microseconds_, or _nanoseconds_ is an unsafe integer. This multiplication can be implemented in C++ with an implementation of `std::remquo()` with sufficient bits in the quotient. String manipulation will also give an exact result, since the multiplication is by a power of 10.
1. If abs(_normalizedSeconds_) ≥ 2<sup>53</sup>, return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-getdurationunitoptions" type="abstract operation">
<h1>
GetDurationUnitOptions (
Expand Down Expand Up @@ -667,7 +476,7 @@ <h1>
<h1>
ComputeFractionalDigits (
_durationFormat_: a DurationFormat Object,
_duration_: a Duration Record,
_duration_: a Temporal.Duration,
): a mathematical value
</h1>
<dl class="header">
Expand All @@ -679,11 +488,11 @@ <h1>
1. Let _result_ be 0.
1. Let _exponent_ be 3.
1. For each row of <emu-xref href="#table-partition-duration-format-pattern"></emu-xref>, except the header row, in table order, do
1. Let _unitOptions_ be the value of _durationFormat_'s internal slot whose name is the Internal Slot value of the current row.
1. Let _unitOptions_ be the value of _durationFormat_'s internal slot whose name is the “Formatter Internal Slot value of the current row.
1. If _unitOptions_.[[Style]] is *"fractional"*, then
1. Let _unit_ be the Unit value of the current row.
1. Assert: IsFractionalSecondUnitName(_unit_) is *true*.
1. Let _value_ be the value of _duration_'s field whose name is the Value Field value of the current row.
1. Let _value_ be the value of _duration_'s internal slot whose name is the “Duration Internal Slot” value of the current row.
1. Set _result_ to _result_ + (_value_ / 10<sup>_exponent_</sup>).
1. Set _exponent_ to _exponent_ + 3.
1. Return _result_.
Expand Down Expand Up @@ -829,7 +638,7 @@ <h1>
<h1>
FormatNumericUnits (
_durationFormat_: a DurationFormat Object,
_duration_: a Duration Record,
_duration_: a Temporal.Duration,
_firstNumericUnit_: a String,
_signDisplayed_: a Boolean,
): a List of Records
Expand Down Expand Up @@ -946,7 +755,7 @@ <h1>
<h1>
PartitionDurationFormatPattern (
_durationFormat_: a DurationFormat,
_duration_: a Duration Record,
_duration_: a Temporal.Duration,
): a List
</h1>
<dl class="header">
Expand All @@ -959,8 +768,8 @@ <h1>
1. Let _signDisplayed_ be *true*.
1. Let _numericUnitFound_ be *false*.
1. While _numericUnitFound_ is *false*, repeat for each row in <emu-xref href="#table-partition-duration-format-pattern"></emu-xref> in table order, except the header row:
1. Let _value_ be the value of _duration_'s field whose name is the Value Field value of the current row.
1. Let _unitOptions_ be the value of _durationFormat_'s internal slot whose name is the Internal Slot value of the current row.
1. Let _value_ be the value of _duration_'s internal slot whose name is the “Duration Internal Slot” value of the current row.
1. Let _unitOptions_ be the value of _durationFormat_'s internal slot whose name is the “Formatter Internal Slot value of the current row.
1. Let _style_ be _unitOptions_.[[Style]].
1. Let _display_ be _unitOptions_.[[Display]].
1. Let _unit_ be the Unit value of the current row.
Expand Down Expand Up @@ -1006,8 +815,8 @@ <h1>
<table class="real-table">
<thead>
<tr>
<th>Value Field</th>
<th>Internal Slot</th>
<th>Duration Internal Slot</th>
<th>Formatter Internal Slot</th>
<th>Unit</th>
<th>NumberFormat Unit</th>
</tr>
Expand Down
Loading
Loading