dlevs / duration-fns

Functions for working with durations.
MIT License
58 stars 6 forks source link

Negative duration format #22

Closed tek-kgong closed 2 years ago

tek-kgong commented 2 years ago

Currently, when we have a negative duration and call duration.toString , it returns a string that is not compatible with certain frameworks like .NET.

For example:

const offset = duration.negate({ minutes: 300 })
duration.toString(offset)); // result: PT-300M 

.NET expects -PT300M.

I am wondering if it is possible to have an option to configure the output of duration.toString.

Here is a link to another bug report that is related that includes documentation from ISO specification

dlevs commented 2 years ago

Hi, Thanks for raising this! What do you think of this fix?

https://github.com/dlevs/duration-fns/pull/25

tek-kgong commented 2 years ago

Looking good to me. Thanks for the quick response!

When will the fix be available?

dlevs commented 2 years ago

No worries!

It's published now as version 3.0.0 https://www.npmjs.com/package/duration-fns