EvanHahn / HumanizeDuration.js

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

Duration does not seem correct #200

Closed mikemajara closed 3 years ago

mikemajara commented 3 years ago

humanizeDuration(new Date(2021, 8, 1, 12).getTime()-new Date().getTime() // returns: 2 months, 1 day, 6 hours, 3 minutes, 48.313 seconds

Today is 1st of July. In a month time, it will be 1st of August.

I fell back to searching for other libs when I saw that date-fns was making the same mistake. I might be missing something, but this does not seem like a human readable date duration given it does not match natural language! I can take a look at the code but I'm looking first to understand if this is expected behavior.

mikemajara commented 3 years ago

Aand I was totally missing something: Dates in JS start with 0 index.

EvanHahn commented 3 years ago

A mistake I've made many times. Glad it's resolved!