Closed mkavanagh closed 9 years ago
Good catch—this is a bug.
Related question: right now, there's a bit of code that returns "0"
if you pass exactly zero.
humanizeDuration(0) // => "0"
What should happen there?
my preference would be to return 0 in the smallest allowed unit in either case - then it still reads as a duration, e.g.
humanizeDuration(0, {units: ['day']}); // => "0 days"
Agreed.
+1
Currently, if you pass
round: true
and the value to be formatted is less than half of the smallest allowed unit, you get an empty string as result:IMO this makes more sense:
(i.e. if we're on the last unit and we haven't added anything to the result yet, do it regardless of whether the unit count is zero)