Open mfwgenerics opened 12 months ago
Thanks for the identifying this issue. parseDuration()
from @internationalized/date
should match the behavior of Temporal.Duration.
Thanks @ktabors
For the benefit of future readers of this issue, here's the behavior of Temporal.Duration
using the polyfill currently hosted on the reference docs.
const duration = Temporal.Duration.from("PT36H")
duration.hours
> 36
duration.days
> 0
I've created a PR since it seems to be unresolved. https://github.com/adobe/react-spectrum/pull/7064 This is my first contribution to an open-source project, so please let me know if there's anything I've missed.
Provide a general summary of the issue here
Valid ISO 8601 durations such as
PT36H
can not be parsed usingparseDuration
from@internationalized/date
because 36 falls outside of the internal range constraint.π€ Expected Behavior?
π― Current Behavior
π Possible Solution
These limits could be removed:
https://github.com/adobe/react-spectrum/blob/f600fdfa2af9f3131b34b1536a790aa1bb348151/packages/%40internationalized/date/src/string.ts#L254
π¦ Context
This current behavior makes it difficult to use
parseDuration
when you are working with time units only.I can't tell exactly how the standard treats the issue, but it does seem that there is no general conversion between units. This makes sense to me, because
P1DT12H
could represent a longer, shorter or equivalent length of time toPT36H
depending on the start date time (due to daylight savings). I believe most other ISO 8601 duration implementations preserve the distinction betweenP1DT12H
andPT36H
.π₯οΈ Steps to Reproduce
Version
3.32.0
What browsers are you seeing the problem on?
Firefox, Chrome, Safari, Microsoft Edge
If other, please specify.
No response
What operating system are you using?
Linux
π§’ Your Company/Team
No response
π· Tracking Issue
No response