-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix and simplify "displayRequired" computation in PartitionDurationFormatPattern #183
Conversation
If `durationFormat.[[HoursStyle]]` is "numeric" or "2-digit" and either `durationFormat.[[HoursDisplay]]` is "always" or `duration.[[Hours]]` is non-zero, then the previous loop iteration set `needSeparator` to `true`. Drive-by change: Use booleans for `displayRequired`.
To determine if the minutes field should always be formatted, we need to inspect all sub-minutes duration fields.
`needSeparator` only needed to be reset to output `"2, 01"`.
Sync `partitionDurationFormatPattern` with the latest spec draft and change it to use an `Intl.DurationFormat` object as the input, so it's easier to compare it against the spec text and because it allows to test more inputs. Includes the fixes for: - tc39/proposal-intl-duration-format#183 - tc39/proposal-intl-duration-format#184
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.
LGTM overall, is this normative or a bugfix? I lean towards the latter but would love to hear your thoughts @anba @sffc @FrankYFTang
yes, I think this PR is better. |
lgtm! note that these errors are (unless I'm mistaken) also fixed in #188, which is waiting for review/re-review |
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.
good catches all -- thanks for finding that error with subsecond unit displays
Sync `partitionDurationFormatPattern` with the latest spec draft and change it to use an `Intl.DurationFormat` object as the input, so it's easier to compare it against the spec text and because it allows to test more inputs. Includes the fixes for: - tc39/proposal-intl-duration-format#183 - tc39/proposal-intl-duration-format#184
Sync `partitionDurationFormatPattern` with the latest spec draft and change it to use an `Intl.DurationFormat` object as the input, so it's easier to compare it against the spec text and because it allows to test more inputs. Includes the fixes for: - tc39/proposal-intl-duration-format#183 - tc39/proposal-intl-duration-format#184
closed as fixed by #188 |
Fixes:
durationFormat.[[SecondsValue]]
should beduration.[[Seconds]]
Simplications:
displayRequired
to a boolean.durationFormat.[[HoursStyle]]
,durationFormat.[[HoursDisplay]]
, andduration.[[Hours]]
don't have to be inspected, instead simply testing ifneedSeparator
istrue
is sufficient.needSeparator
doesn't need to be reset. This step was only present for compatibility with previous revisions to output strings like1, 03
for{hours: 1, seconds: 3}
(see hours: "numeric" w/ 0 in minutes and non 0 in seconds cause strange output. #170).