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

Should we support fractional minutes and hours? #65

Open
sffc opened this issue Aug 3, 2021 · 6 comments
Open

Should we support fractional minutes and hours? #65

sffc opened this issue Aug 3, 2021 · 6 comments
Labels
enhancement New feature or request v2

Comments

@sffc
Copy link
Collaborator

sffc commented Aug 3, 2021

#64 discusses a new fractionalDigits option for seconds and lower. Should we support fractional minutes and hours as well? For example, "2.5 hours" or "2.5 minutes".

@sffc
Copy link
Collaborator Author

sffc commented Aug 5, 2021

@eemeli mentioned today that we should prioritize fractional digits up to hours.

Here's how we can do it fairly elegantly.

  • Add a new style, valid for hours through nanoseconds: "fractional"
  • Make "fractional" be the default for [milli/micro/nano]seconds

The behavior for subsecond digits is as described in #64. When second: "fractional" is present, the result is shown as fractions of a minute, like "1.5 minutes". When minute: "fractional", second: "fractional" is present, the result is shown as fractions of an hour, like "1.5 hours".

Arithmetic is required, but not any sort of fancy arithmetic like Temporal can perform. We just always assume exactly 60 seconds in a minute and exactly 60 minutes in an hour.

@eemeli
Copy link
Member

eemeli commented Aug 6, 2021

One other possibility would be to add an option fractionalUnits to explicitly control the units that fractionalDigits applies to. That might also make it easier to reason about the corner cases that were discussed on the call yesterday. More specifically:

  • Add a new option fractionalUnits, accepting values "nanoseconds", ..., "years" and defaulting to "seconds"
  • If a non-numeric style is defined for a sub-second unit and fractionalUnits is not defined, the default value of fractionalUnits takes the value of the smallest non-numeric unit.
  • If the "always" display style is defined for a yet smaller unit, fractionalUnits defaults to that unit instead.
  • If fractionalUnits is explicitly defined, and a non-numeric style is also defined for a smaller unit, fractionalDigits has no effect.

@ryzokuken
Copy link
Member

ryzokuken commented Aug 13, 2021

At the possible cost of making things a bit more complicated, I do really like @eemeli's suggestion here.

Either way, I think it's alright for fractionalDigits to apply to any units with style "numeric" (as long as there isn't a smaller non-numeric or display: "always" unit), therefore allowing fractional minutes and hours (and maybe days? maybe not since not all days at 24h, even in Temporal) and lowering the amount of "boundaries" that developers need to learn and remember.

@ryzokuken
Copy link
Member

This is not supported in the current version of the proposal, but could be easily done in a follow-on.

@ryzokuken
Copy link
Member

I think there's not much to add here. Fractional minutes and hours could be added with minor changes but are not in the scope of the current proposal. Do folks agree it's fine to close this issue for now and move on?

@sffc
Copy link
Collaborator Author

sffc commented Aug 23, 2023

Largely a duplicate of #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v2
Projects
None yet
Development

No branches or pull requests

4 participants