ecma402
ecma402 copied to clipboard
How to format "0.50 days", "0.25 hours", or "3.25 minutes" in DurationFormat
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
@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).
Duplicate of https://github.com/tc39/proposal-intl-duration-format/issues/65, I think.
@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"?
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?
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.
I think the current spec satisfies fractional numeric formatting well enough, right?
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.
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.
True; it works for seconds, milliseconds, and microseconds.
I think this issue is waiting on action from @ryzokuken.
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?
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.
Notes from November 2024 call: https://github.com/tc39/ecma402/blob/master/meetings/notes-2023-11-16.md#style-fractional