Closed graemian closed 4 years ago
Hmm, that seems like it should work.
I don't have lots of time to maintain this module, unfortunately—any chance you could attempt a pull request?
Running into the same issue. Happy to do a PR, but first I want to define the problem.
const ms = 1000 * 60 * 60 * 1.5 // 1.5 hours
humanizeDuration(ms, {
units: ['h', 'm'],
largest: 1,
})
// Current output: "1 hour"
// Expected output?: "1.5 hours"
humanizeDuration(ms, {
units: ['h'],
largest: 1,
})
// Current output: "1.5 hours"
// Expected output: "1.5 hours"
Does the first call output a buggy result in your opinion? Should these 2 calls return the same output?
EDIT: May have found an easy solution. Change this line
to this:
if (i + 1 === len || (has(options, 'largest') && options.largest + 1 === len)) {
const ms = 1000 * 60 * 60 * 1.5 // 1.5 hours
humanizeDuration(ms, {
units: ['h', 'm'],
largest: 1,
})
// Output: "1.5 hours"
Tests still pass after this change.
That change seems reasonable to me.
This feels like a bugfix and not a breaking change, but are there any cases where it could arguably be a breaking change? If so, I'm more hesitant to make this change.
Understandable. The fact that the existing tests stilled passed after my modifications is worrisome. I don't have the time to discover breaking changes, so it may be better to leave this alone.
I admit that this is the kind of thing that makes me not want to maintain this library any more—there is a large matrix of possible options that are hard to test exhaustively. (I'm sure it could be done by a more competent maintainer.) For example, what happens if you throw round
into the mix here?
I'm inclined to keep things as is. However, if someone wants to fork this library to fix this bug and make some additional changes (like the one in #141), I'd link to that fork.
There hasn't been movement on this issue in several months so I'm going to close.
Feel free to let me know if you'd like me to reopen—I don't want to stop important discussion, I just want to clean up old issues.
I'd like to have output like "12.4 days" or "6.5 weeks", but I can't figure out how to get this.
I tried { largest: 1, round: false } but it doesn't work. Is this possible?