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

Duration.toISOString() should use a set precision for seconds #2366

Closed
creedasaurus opened this issue Jul 4, 2023 · 1 comment · Fixed by #2367
Closed

Duration.toISOString() should use a set precision for seconds #2366

creedasaurus opened this issue Jul 4, 2023 · 1 comment · Fixed by #2367
Labels

Comments

@creedasaurus
Copy link
Contributor

Describe the bug

Problem: The Duration.toISOString() will format an ISO string with arbitrary precision floating point seconds. Although the specification doesn't define the precision the seconds field should have, it would likely be better to keep to some common format. The moment library uses the millisecond precision, as does the Java Duration.

I noticed this behavior when moving from moment. We were sending ISO durations to our Java backend and it quickly started throwing exceptions trying to parse the durations.

Expected behavior

Example:

Input: duration(2/3)
Expected: PT0.001S
Actual: PT0.0006666666666666666S

Information

  • Day.js Version [e.g. v1.11.8]
  • OS: All
  • Browser All
  • Time zone: N/A
@github-actions
Copy link

🎉 This issue has been resolved in version 1.11.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

1 participant