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

In digital format, what should we do with grouping separators in hours, minutes and seconds field when the value is > 60 or > 999? #192

Open
FrankYFTang opened this issue Apr 11, 2024 · 7 comments · May be fixed by #198
Assignees

Comments

@FrankYFTang
Copy link
Collaborator

FrankYFTang commented Apr 11, 2024

What should be the expected output of the following?

const df = new Intl.DurmationFormat("en", {style: "digital"})
df.format({hours: 300, minutes: 60, seconds: 120})

should it output "300:60:120" ? but how does it make sense?

How about

df.format({hours: 20, minutes: 3, seconds: 1234567})

"20:03:1,234,567" ?

or
"20:03:1234567" ?

Currently, the spec will ask the implementation to output "20:03:1,234,567 "

@FrankYFTang
Copy link
Collaborator Author

@ben-allen @ryzokuken @sffc

@sffc
Copy link
Collaborator

sffc commented Apr 12, 2024

The spec doesn't do balancing except in the narrow case of fractional second units in numeric mode. Users should eventually use Temporal.Duration to perform their balancing. So I believe this is mostly WAI. Except perhaps for this part:

"20:03:1,234,567 "

I think perhaps we should suppress grouping separators in digital format because otherwise it looks too confusing.

@FrankYFTang
Copy link
Collaborator Author

FrankYFTang commented Apr 12, 2024

suppress grouping separators in digital format

Yea, that is the main reason I file this bug.
But which part should we suppress grouping separators in digital format?
All? or while unit is hours, minutes and seconds?

consider the following (I included the outcome of the current pec. Notice we need to consider what should do with days or larger units)

const df = new Intl.DurationFormat("en", {style: "digital"})
df.format({hours: 1234567, minutes: 20, seconds: 45}) // => "1,234,567:20:45"
df.format({hours: 12, minutes: 1234567, seconds: 20}) // => "12:1,234,567:20"
df.format({hours: 12, minutes: 34, seconds: 1234567}) // => "12:34:1,234,567"
df.format({hours: 12, minutes: 34, seconds: 56, milliseconds: 1234567}) //  => "12:34:1,290.567"
df.format({days: 1234567, hours: 3, minutes: 20, seconds: 45}). // => "1,234,567 days, 3:20:45"

what should be the use grouping suppressed output we should aim to change to?

@FrankYFTang
Copy link
Collaborator Author

@anba

@anba
Copy link
Contributor

anba commented Apr 15, 2024

I think perhaps we should suppress grouping separators in digital format because otherwise it looks too confusing.

That suggestion sounds reasonable to me.

Using the example inputs from #192 (comment):

Duration Current Proposed
{hours: 1234567, minutes: 20, seconds: 45} 1,234,567:20:45 1234567:20:45
{hours: 12, minutes: 1234567, seconds: 20} 12:1,234,567:20 12:1234567:20
{hours: 12, minutes: 34, seconds: 1234567} 12:34:1,234,567 12:34:1234567
{hours: 12, minutes: 34, seconds: 56, milliseconds: 1234567} 12:34:1,290.567 12:34:1290.567
{days: 1234567, hours: 3, minutes: 20, seconds: 45} 1,234,567 days, 3:20:45 1,234,567 days, 3:20:45

@FrankYFTang
Copy link
Collaborator Author

I support @anba 's proposal

@sffc
Copy link
Collaborator

sffc commented May 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants