tc39 / proposal-intl-duration-format

https://tc39.es/proposal-intl-duration-format
MIT License
165 stars 18 forks source link

fractionalDigits should fallback to 0 #112

Closed FrankYFTang closed 2 years ago

FrankYFTang commented 2 years ago

in step 18 of https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat

Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined).

This mean if the options does not have a "fractionalDigits" then durationFormat.[[FractionalDigits]] will be set to undefined.

I think this is not right, should we set it to 0 as the fallback as

Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, 0).

Otherwise we will run into the following problme: A. in https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.resolvedOptions

4. For each row of Table 2, except the header row, in table order, do
a. Let p be the Property value of the current row.
b. Let v be the value of df's internal slot whose name is the Internal Slot value of the current row.
c. Assert: v is not undefined.

but in step 4-c v will be undefined unless we change it. Also the statement https://tc39.es/proposal-intl-duration-format/#sec-properties-of-intl-durationformat-instances

[[FractionalDigits]] is a Number value, identifying the number of fractional digits to be used with numeric styles."

will not be true then

@ryzokuken @sffc