Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PartitionDurationFormatPattern need to handle undefined field in duration #90

Closed
FrankYFTang opened this issue Dec 30, 2021 · 1 comment · Fixed by #92
Closed

PartitionDurationFormatPattern need to handle undefined field in duration #90

FrankYFTang opened this issue Dec 30, 2021 · 1 comment · Fixed by #92
Assignees
Labels
bug Something isn't working

Comments

@FrankYFTang
Copy link
Collaborator

FrankYFTang commented Dec 30, 2021

In the proposal, there are two places calling PartitionDurationFormatPattern with the value return by ToPartialDuration.

https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.format

1.4.3 Intl.DurationFormat.prototype.format ( duration )
...
3. Let record be ? ToPartialDuration(duration).
4. Let formatted be ? PartitionDurationFormatPattern(df, record).

and
https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.formatToParts

1.4.4 Intl.DurationFormat.prototype.formatToParts ( duration )
...
3. Let record be ? ToPartialDuration(duration).
4. Let formatted be ? PartitionDurationFormatPattern(df, record).

Notice, in ToPartialDuration
https://tc39.es/proposal-temporal/#sec-temporal-topartialduration
some of the field might be "undefined"

But inside 1.1.2 PartitionDurationFormatPattern ( durationFormat, duration )
https://tc39.es/proposal-intl-duration-format/#sec-partitiondurationformatpattern

step 2-k-i

i. Set value to duration.[[Microseconds]] + duration.[[Nanoseconds]] / 1000.

but either duration.[[Microseconds]] and duration.[[Nanoseconds]] could be undefined.

and step 2-k-ii-1

1. Set value to duration.[[Milliseconds]] + value / 1000.

duration.[[Milliseconds]] could be undefined
and step 2-k-ii-2-a

a. Set value to duration.[[Seconds]] + value / 1000.

duration.[[Seconds]] could be undefined

and step 2-l-i

i. Set value to duration.[[<valueSlot>]].

any duration.[[]] could be undefined and resulting value is undefined
but then 2-p

p. Let num be ! FormatNumeric(durationFormat.[[NumberFormat]], value).

will pass undefined as 2nd argument to FormatNumeric
and step 2-t-ii

ii. Let prv be ! ResolvePlural(pr, value).

will pass undefined as 2nd argument to ResolvePlural

I don't think any of above are correct.

@sffc @ryzokuken

@FrankYFTang FrankYFTang added the bug Something isn't working label Jan 6, 2022
@sffc
Copy link
Collaborator

sffc commented Jan 13, 2022

ryzokuken added a commit to ryzokuken/proposal-intl-duration-format that referenced this issue Apr 21, 2022
Switch from ToPartialDuration to ToTemporalDurationRecord to fix
undefined handling bug.

Fixes: tc39#90
ryzokuken added a commit to ryzokuken/proposal-intl-duration-format that referenced this issue Apr 28, 2022
Switch from ToPartialDuration to ToTemporalDurationRecord to fix
undefined handling bug.

Fixes: tc39#90
ryzokuken added a commit that referenced this issue May 19, 2022
* normative: fix topartialduration issue

Switch from ToPartialDuration to ToTemporalDurationRecord to fix
undefined handling bug.

Fixes: #90

* fixup: [spec] `npm run build`

* fixup: [spec] `npm run build`

* fixup: [spec] `npm run build`

Co-authored-by: ryzokuken <ryzokuken@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants