tc39 / proposal-intl-duration-format

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

Formatted numeric parts incorrectly handled #223

Closed anba closed 2 weeks ago

anba commented 2 weeks ago

Two issues:

  1. PartitionDurationFormatPattern, step 4.e.i:

    4.e.i. Append FormatNumericUnits(durationFormat, duration, unit, signDisplayed) to result.

This step doesn't handle the case when FormatNumericUnits returns an empty list.

Instead something like:

4.e.i. Let numericPartsList be FormatNumericUnits(durationFormat, duration, unit, signDisplayed). 4.e.ii. If numericPartsList is not empty, append numericPartsList to result.


  1. FormatNumericUnits appends formatted elements to numericPartsList instead of using list-concatenation.

16.b. Append FormatNumericHours(durationFormat, hoursValue, signDisplayed) to numericPartsList.

Needs to be:

16.b. Let hoursParts be FormatNumericHours(durationFormat, hoursValue, signDisplayed). 16.c. Set numericPartsList to the list-concatenation of numericPartsList and hoursParts.

Same goes for the calls to FormatNumericMinutes and FormatNumericSeconds.

ben-allen commented 2 weeks ago

Thanks for these! I'm putting up a PR with commits resolving each of the issues you've identified right now.