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

Consider adding a DecimalSecond variant with automatic fraction digits #6008

Open
sffc opened this issue Jan 15, 2025 · 1 comment
Open

Consider adding a DecimalSecond variant with automatic fraction digits #6008

sffc opened this issue Jan 15, 2025 · 1 comment
Labels
C-datetime Component: datetime, calendars, time zones T-enhancement Type: Nice-to-have but not required

Comments

@sffc
Copy link
Member

sffc commented Jan 15, 2025

In #5979, I'm implementing auto time precision by calculating the number of fractional digits with integer operations on the nanosecond ahead of time. It would be more efficient if we could read the number of fractional digits when we actually need it and after the nanosecond has been converted to a FixedDecimal.

An easy way to do this would be to add a DecimalSecond variant for automatic fractional second digits. However, this would make DecimalSecond deviate from UTS 35.

It would also eliminate the need to carry the fractional_second_digits_from_nanosecond function.

Please upvote this issue if you would like to see automatic fraction digits. This will help us make the case to add the proposed option.

@sffc sffc added T-enhancement Type: Nice-to-have but not required C-datetime Component: datetime, calendars, time zones labels Jan 15, 2025
@sffc
Copy link
Member Author

sffc commented Jan 15, 2025

I explored three different ways to implement auto fractional second digits:

  1. Compute the number of trailing zeros from the integer
    • Pro: Only runs when we need it to run
    • Con: Requires an additional, somewhat-expensive operation to check the trailing zeros, when we can get the number for free later after it is converted to a FixedDecimal
  2. Store the FixedDecimal representation in ExtractedInput
    • Pro: Calculating the trailing zero count is free
    • Con: The number is converted even if nanoseconds are not going to be displayed
  3. Add a variant to DecimalSecond (this issue)
    • Pro: We can calculate information exactly where we need it in source
    • Con: Impacts public API in a way that makes it diverge from UTS 35

Here is a backup of my work on options 1 and 2:

main...sffc:omnicu:archive/auto-fractional-second-digits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-datetime Component: datetime, calendars, time zones T-enhancement Type: Nice-to-have but not required
Projects
None yet
Development

No branches or pull requests

1 participant