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
Update README.md #106
base: main
Are you sure you want to change the base?
Update README.md #106
Conversation
Close #104
README.md
Outdated
milliseconds: "narrow", | ||
fractionalDigits: 2, | ||
}).format(duration); | ||
// => 12s 345.60ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current spec draft text uses Intl.ListFormat
, which means the results will look more like:
12 seconds, 345 milliseconds, and 600 microseconds
and
12 seconds, 345ms, and 600 microseconds
.
}; | ||
|
||
new Intl.DurationFormat("en").format(duration); | ||
// => 2 hr 46 min 40 sec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 hours, 46 minutes, and 40 seconds
according to the current draft text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/tc39/proposal-intl-duration-format/pull/127/files guess this modifies the behaviour you explain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctly matches behavior of Intl.ListFormat. Current spec doesn't seem to do fractionalDigits correctly, though? Might need to be another issue
|
||
// Example using fractionalDigits | ||
new Intl.DurationFormat("en", { fractionalDigits: 2 }).format(duration); | ||
// => 12 sec, 345 ms, 600 μs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to reduce the surprise with this behavior, a solution would be to set the default style for milliseconds, microseconds, and nanoseconds to be "numeric", even in non-digital styles.
Either way, please include an example with fractionalDigits and digital format.
Let's get back to this once we've finalized all the normative issues? |
@ben-allen has a new PR in #168 which makes most of these changes; after that PR is merged, Ben will take one final look at this PR and close it if all of its loose ends have been resolved. |
#168 has been merged. |
Close #104