Add toString method
I think it would be useful to have a method similar to toSeconds, but for converting a Duration object to a ISO8601 duration string.
For example:
toString({
"weeks": 0,
"years": 3,
"months": 6,
"days": 4,
"hours": 12,
"minutes": 30,
"seconds": 5
})
// P3Y6M4DT12H30M5S
I don't see why not 😊 Are you willing to create a PR?
LMAO I came here to use this lib to parse durations because https://github.com/date-fns/date-fns/issues/3150 and now I see that this lib does not format durations :D
thats correct and I don't think it fit's the purpose of this module either, unfortunately.
I'd rather look at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat for formatting (or a polyfill) since it's something that's coming to the platform 👍
It would be nice for now, because it's not browser/node native, to be able to perform parse/format with one lib. But it's ok for us, we use both your lib and date-fns, so for that, thank you ❤️