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
Add parseISODuration
function
#3768
base: main
Are you sure you want to change the base?
Conversation
parseISODuration
function
hours = 0, | ||
minutes = 0, | ||
seconds = 0, | ||
] = match; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the idea of assigning undefined values to 0
. I know that formatISODuration
assigns zero values, but these two functions together lose information. I recently played with Temporal's duration, and there you can format(parse('P1Y2M')) === 'P1Y2M'
, which I think is a very good approach. While we can't change formatISODuration
in v3, we can move in that direction.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! I've updated the implementation to preserve undefined values instead of assigning them to 0.
This is a continuation of PR #3151 by @matinzd.
Mainly I have: