sindresorhus / pretty-ms

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
MIT License
1.08k stars 65 forks source link

Add support for years #16

Closed lykmapipo closed 7 years ago

lykmapipo commented 7 years ago
var prettyMs = require('pretty-ms');
prettyMs(133700000000);

//"1547d 10h 53m 20s"

Days should be in year at least

sindresorhus commented 7 years ago

Months and years depend on when you're calculating. Do you want the months and year when it's calculated or when the ms number was produced? Those might be different. That's why I didn't add it initially, since month and year can be different depending on when it's calculated.

Can you elaborate on your use-case? What do you need it for?

sindresorhus commented 7 years ago

I've been thinking about this and I'm ok with adding the year here, but not months. We can assume 365 days as it's just an estimation anyways. So 1547d 10h 53m 20s would become 4y 87d 10h 53m 20s.