EvanHahn / HumanizeDuration.js

361000 becomes "6 minutes, 1 second"
https://evanhahn.github.io/HumanizeDuration.js/
The Unlicense
1.64k stars 175 forks source link

There is an issue with leap years #154

Closed genu closed 5 years ago

genu commented 5 years ago

I'm not sure if this is related to #141 but There is an issue with working with leap years.

For example:

// startDate: 01/01/2003
// endDate: 12/31/2004
humanizeDuration(startDate.diff(endDate), { largest: 4, round: true });
/ / 2 year, 1 day

I think this should just be 2 years.

Ref: https://www.wolframalpha.com/input/?i=01%2F01%2F2003+to+12%2F31%2F2004

EvanHahn commented 5 years ago

HumanizeDuration.js isn't aware of times—it just humanizes millisecond durations.

For example, it knows how to humanize 12345 milliseconds, but it doesn't care when that interval is. Is that 12345 milliseconds starting January 1? Starting a week ago? Starting 5 years from now? This library doesn't care.

You might be able to change this with the unitMeasures option. See the documentation for more.

Closing this because it's out of scope for the library, but feel free to continue discussing here (or request that I reopen it).