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

How to format "0.50 days", "0.25 hours", or "3.25 minutes" #89

Open
FrankYFTang opened this issue Dec 29, 2021 · 12 comments
Open

How to format "0.50 days", "0.25 hours", or "3.25 minutes" #89

FrankYFTang opened this issue Dec 29, 2021 · 12 comments
Labels

Comments

@FrankYFTang
Copy link
Collaborator

I am reading the spec about "fractionalDigits" but I cannot figure out how to create an object to formating someting like "0.50 days", "1.25 hours", or "3.25 minutes" w/ {fractionalDigits:2} . Is that intentionally unsupported?

@sffc @ryzokuken

@ryzokuken
Copy link
Member

ryzokuken commented Dec 29, 2021

@FrankYFTang yes. In the case of days, it's hard to say how many hours constitute 0.5 days, since not all days are equally long. In the case of smaller units, Temporal assumes all units are of fixed size for now but this might not hold in the future when (and if at all) we decide to add support for alternate time-keeping systems like we currently support alternate calendars.

Therefore, only seconds and below can be represented as fractions for now but we'd debated loosening that upto hours (but decided not to allow it yet).

@sffc
Copy link
Collaborator

sffc commented Dec 29, 2021

Duplicate of #65, I think.

@FrankYFTang
Copy link
Collaborator Author

@FrankYFTang yes. In the case of days, it's hard to say how many hours constitute 0.5 days, since not all days are equally long.

I understand for a specific date, the number of hours may not be 24, but for a unit of "day" for the purpose of formatting why is it not 24 hours? Also, how about "0.25 hours", or "3.25 minutes". In what sense that 15 minutes not be counted as "0.25 hours" and 195 seconds not counted as "3.25 minutes"?

@sffc
Copy link
Collaborator

sffc commented Dec 30, 2021

It is a valid use case that is not supported right now.

I'm okay punting this to DurationFormat v2, unless it requires breaking something we've done in v1.

@ryzokuken Can you verify that we have a path forward for supporting this feature in a future proposal in a backwards-compatible way?

@sffc
Copy link
Collaborator

sffc commented Jan 13, 2022

Discussion 2021-01-13: https://github.com/tc39/ecma402/blob/master/meetings/notes-2022-01-13.md#how-to-format-050-days-025-hours-or-325-minutes-89

Conclusion: @ryzokuken to come up with a spec text modification to demonstrate this possibility, but we will not put it into the current proposal.

@ryzokuken
Copy link
Member

I think the current spec satisfies fractional numeric formatting well enough, right?

@ryzokuken ryzokuken added the done label Jun 30, 2022
@sffc
Copy link
Collaborator

sffc commented Jul 2, 2022

No, we don't support fractions of anything other than seconds. The ask here is to show how a potential Intl.DurationFormat V2 proposal could add fractional formatting of other units.

@sffc sffc removed the done label Jul 2, 2022
@FrankYFTang
Copy link
Collaborator Author

No, we don't support fractions of anything other than seconds.

hum... I though the current spec said
j. If unit is "seconds", "milliseconds", or "microseconds"

not just seconds.

@sffc
Copy link
Collaborator

sffc commented Jul 13, 2023

True; it works for seconds, milliseconds, and microseconds.

I think this issue is waiting on action from @ryzokuken.

@sffc
Copy link
Collaborator

sffc commented Aug 23, 2023

For example, would it be possible in the future to start accepting { seconds: "numeric" } and have expected behavior? How does that interact with digital style?

@sffc
Copy link
Collaborator

sffc commented Nov 16, 2023

We discussed some potential approaches in the November 2024 call (and previously). We think it can be fairly easily added in v2, and spec refactors that @ben-allen is working on should make it implementable.

@sffc
Copy link
Collaborator

sffc commented Nov 16, 2023

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

No branches or pull requests

3 participants