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

TimeDelta always returning a PT in seconds #1576

Closed
MiPnamic opened this issue Apr 27, 2024 · 2 comments
Closed

TimeDelta always returning a PT in seconds #1576

MiPnamic opened this issue Apr 27, 2024 · 2 comments

Comments

@MiPnamic
Copy link

As per the mentioned iso8601 - Duration a Duration of 1 day can be expressed as:

  • P1D
  • PT24H
  • PT1440M
  • PT86400S

The current TimeDelta Display implementation always returns the longer format in seconds, which is a practical solution. However, it can be challenging to read for more complex PT values.

For example, a valid 10-day, 2-hour, and 30-minute TimeDelta gets translated to PT873000S instead of P10DT2H30M.

Would you consider adding what has been referred to as "nominal" components in future releases?

@pitdicker
Copy link
Collaborator

The different strings you write to express one day are not meant to work identical by ISO 8601.

In P1D one day can be less or more than 24 hours. That may be the case if the duration includes a day with a daylight saving time change. In the same way PT1440M is intended to work slightly different from PT86400S if there is a leap second.

#1282 is our plan to add a CalendarDuration type that can work correctly with a duration that is build up out of multiple components (months, days, minutes, seconds and nanoseconds).

Recently in #1328 we changed TimeDelta/Duration to format its value with only seconds. That is the only correct way to format the value according to ISO 8601. Using larger components would change the meaning of the formatted string, and work incorrectly when read back with more correct/advanced implementations such as CalendarDuration.

@MiPnamic
Copy link
Author

Thank you so much for the explanation; this is not a duplicate of #1282, but it was not even an issue then.
I'll follow #1282 for updates.

Thank you for your time.

@djc djc reopened this Apr 28, 2024
@djc djc closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants