icholy / Duration.js

MIT License
185 stars 14 forks source link

[Feature request] Add support for ISO 8601 durations #19

Closed cedx closed 2 years ago

cedx commented 2 years ago

It's quite common nowadays to deal with ISO 8601 durations (cf. https://en.wikipedia.org/wiki/ISO_8601#Durations). Currently we have to convert the format string ourselves before using it with the Duration class. It would be cool if the Duration.parse() method could handle the ISO 8601 format.

// What I can do:
Duration.parse("5d4h3m2s")

// What I want to do:
Duration.parse("P5DT4H3M2S")
icholy commented 2 years ago

Have you considered https://moment.github.io/luxon/api-docs/index.html#duration ?

cedx commented 2 years ago

No 😄 I had used it a long time ago and completely forgotten about it. I just searched for "duration" on NPM and found that your library was the most interesting in terms of APIs. Thank you for reminding me that Luxon exists.

I guess you don't plan to add this feature? Do I close this ticket?

icholy commented 2 years ago

I might consider a Duration.parseISO, but I won't be working on it anytime soon.

cedx commented 2 years ago

OK, I understand. I prefer to close this ticket then. Thank you for taking the time to respond.