Skip to content
Merged
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
43b1115
Add missing check that 'numberingSystem' is not undefined
anba Jul 25, 2022
913a65c
GetDurationUnitOptions requires that prevStyle is a String value
anba Jul 25, 2022
c7b5ac8
Remove unnecessary initialisation for value and pass value as a Numbe…
anba Jul 25, 2022
ce0a0d3
Creating internal Intl objects is infallible
anba Jul 25, 2022
03cff7c
Add missing Oxford comma
anba Jul 25, 2022
6e7153d
Use correct NumberFormat variable
anba Jul 25, 2022
8f995d2
Correctly call MakePartsList with a List of Records
anba Jul 25, 2022
fdc27d6
Use computed slot names
anba Jul 25, 2022
7968d7c
Add a note that CreatePartsFromList will need to be changed
anba Jul 25, 2022
2318b2f
Follow PartitionDateTimeRangePattern instead of using 'Stop iteration'
anba Jul 25, 2022
1d54ece
Invert the condition instead of using 'Skip to the next iteration'
anba Jul 25, 2022
1297f00
Add missing definition for 'display' variable
anba Jul 25, 2022
6692e97
Don't append [[Unit]] field to the result list
anba Jul 25, 2022
e1a7fec
Make ToDurationRecord more similar to ToTemporalDurationRecord/ToTemp…
anba Jul 25, 2022
0c95440
Rename DurationSign to DurationRecordSign to avoid clashing with Temp…
anba Jul 25, 2022
cf89536
Use 'of' instead of 'in' to match ECMA-402
anba Jul 25, 2022
2fb3173
Change the operations from Temporal to be more like the rest of ECMA-402
anba Jul 25, 2022
7d0c057
Enumerate Record fields for iteration to match ECMA-402
anba Jul 25, 2022
a8681d3
Remove `next row` which is undefined for the last row
anba Jul 25, 2022
5789f68
Only append time separator when the next value will be displayed
anba Jul 25, 2022
1f87460
Add a TODO note about incorrect handling of the time separator symbol
anba Jul 25, 2022
8eb0100
Use "numeric" as the default style when the previous style is "numeri…
anba Jul 25, 2022
dfa1ce7
Use correct markup for string literals
anba Jul 25, 2022
a90d077
Use correct markup for null and number values
anba Jul 25, 2022
7fe6e79
Use correct markup for throwing a RangeError
anba Jul 25, 2022
8f0890b
Add missing dots
anba Jul 25, 2022
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
16 changes: 8 additions & 8 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,9 @@ contributors: Ujjwal Sharma, Younies Mahmoud
1. Let _style_ be the current value of the _styleSlot_ slot of _durationFormat_.
1. Let _nextStyle_ be the current value of the _nextStyleSlot_ slot of _durationFormat_.
1. Let _nfOpts_ be ! OrdinaryObjectCreate(`null`).
1. Let _value_ be 0.
1. Let _done_ be *false*.
1. If _unit_ is `"seconds"`, `"milliseconds"` or `"microseconds"` and _nextStyle_ is `"numeric"`, then
1. Set _value_ to _duration_.[[Microseconds]] + _duration_.[[Nanoseconds]] / 1000.
1. Let _value_ be _duration_.[[Microseconds]] + _duration_.[[Nanoseconds]] / 1000.
1. If _unit_ is `"seconds"` or `"milliseconds"`, then
1. Set _value_ to _duration_.[[Milliseconds]] + _value_ / 1000.
1. If _unit_ is `"seconds"`, then
Expand All @@ -281,13 +280,13 @@ contributors: Ujjwal Sharma, Younies Mahmoud
1. Perform ! CreateDataPropertyOrThrow(_nfOpts_, `"minimumFractionDigits"`, _durationFormat_.[[FractionalDigits]]).
1. Set _done_ to *true*.
1. Else,
1. Set _value_ to the current value of the _valueSlot_ slot of _duration_.
1. Let _value_ be the current value of the _valueSlot_ slot of _duration_.
1. If _style_ is `"2-digit"`, then
1. Perform ! CreateDataPropertyOrThrow(_nfOpts_, `"minimumIntegerDigits"`, `2`).
1. If _value_ is *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> and _display_ is `"auto"`, then
1. If _value_ is 0 and _display_ is `"auto"`, then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I keep falling in the JavaScript trap of "this will be freed once out of scope" 🤦

1. Skip to the next iteration.
1. Let _nf_ be ? Construct(%NumberFormat%, &laquo; _durationFormat_.[[Locale]], _nfOpts_ &raquo;).
1. Let _num_ be ! FormatNumeric(_durationFormat_.[[NumberFormat]], _value_).
1. Let _num_ be ! FormatNumeric(_durationFormat_.[[NumberFormat]], 𝔽(_value_)).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

𝔽 will need to be removed after Intl.NumberFormat V3 lands. But this will lead to a different output for some inputs, so if we care about the exact same output, this line will need to be changed to 𝔽(ℝ(value)).

Or alternatively we could make Intl.DurationFormat dependent on Intl.NumberFormat V3.

I guess it's better to open a separate issue about the precision, because Temporal typically generates the precise result.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @sffc. How do you think we should proceed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#110 has a concrete example to show the possible precision loss.

1. Let _dataLocale_ be _durationFormat_.[[DataLocale]].
1. Let _dataLocaleData_ be the current value of the _dataLocale_ slot of %DurationFormat%.[[LocaleData]].
1. If _style_ is `"2-digit"` or `"numeric"`, then
Expand All @@ -297,7 +296,7 @@ contributors: Ujjwal Sharma, Younies Mahmoud
1. Append the new Record { [[Type]]: `"literal"`, [[Value]]: _separator_} to the end of _result_.
1. Else,
1. Let _pr_ be ? Construct(%PluralRules%, &laquo; _durationFormat_.[[Locale]] &raquo;).
1. Let _prv_ be ! ResolvePlural(_pr_, _value_).
1. Let _prv_ be ! ResolvePlural(_pr_, 𝔽(_value_)).
1. Let _template_ be the current value of the _prv_ slot of the _unit_ slot of the _style_ slot of _dataLocaleData_.[[formats]].
1. Let _parts_ be ! MakePartsList(_template_, _unit_, _num_).
1. Let _concat_ be an empty String.
Expand Down Expand Up @@ -332,7 +331,8 @@ contributors: Ujjwal Sharma, Younies Mahmoud
1. Let _options_ be ? GetOptionsObject(_options_).
1. Let _matcher_ be ? GetOption(_options_, `"localeMatcher"`, `"string"`, &laquo; `"lookup"`, `"best fit"` &raquo;, `"best fit"`).
1. Let _numberingSystem_ be ? GetOption(_options_, `"numberingSystem"`, `"string"`, *undefined*, *undefined*).
1. If _numberingSystem_ does not match the Unicode Locale Identifier `type` nonterminal, throw a `RangeError` exception.
1. If _numberingSystem_ is not *undefined, then
1. If _numberingSystem_ does not match the Unicode Locale Identifier `type` nonterminal, throw a `RangeError` exception.
1. Let _opt_ be the Record { [[localeMatcher]]: _matcher_, [[nu]]: _numberingSystem_ }.
1. Let _r_ be ResolveLocale(%DurationFormat%.[[AvailableLocales]], _requestedLocales_, _opt_, %DurationFormat%.[[RelevantExtensionKeys]], %DurationFormat%.[[LocaleData]]).
1. Let _locale_ be r.[[locale]].
Expand All @@ -341,7 +341,7 @@ contributors: Ujjwal Sharma, Younies Mahmoud
1. Let _style_ be ? GetOption(_options_, `"style"`, `"string"`, &laquo; `"long"`, `"short"`, `"narrow"`, `"digital"` &raquo;, `"long"`).
1. Set _durationFormat_.[[Style]] to _style_.
1. Set _durationFormat_.[[DataLocale]] to _r_.[[dataLocale]].
1. Let _prevStyle_ be *undefined*.
1. Let _prevStyle_ be the empty String.
1. For each row in <emu-xref href="#table-duration-components"></emu-xref>, except the header row, in table order, do
1. Let _styleSlot_ be the Style Slot value.
1. Let _displaySlot_ be the Display Slot value.
Expand Down