Add explicit option to return "0 seconds" instead of "no time"
Hi.
I'd like the ability to explicitly instruct Humanizer to return "0 seconds" instead of "no time".
Thank you.
Edit: For example,
TimeSpan.Zero.Humanize(1, toWords: true)); // returns "no time"
TimeSpan.Zero.Humanize(1, toWords: false)); // also returns "no time", but maybe this should return "0 seconds" instead?
To clarify, does this issue entail making it so that when toWords is false, the method always returns 0 seconds (or 0 minutes, 0 hours, etc., depending on what the minimum time unit is), when the time span is zero?
Hi.
Yes, that is correct.
Current behavior:
TimeSpan.Zero.Humanize(1, toWords: true)); // returns "no time"
TimeSpan.Zero.Humanize(1, toWords: false)); // returns "no time"
New requested behavior:
TimeSpan.Zero.Humanize(1, toWords: true)); // returns "no time"
TimeSpan.Zero.Humanize(1, toWords: false)); // returns "0 seconds"
TimeSpan.Zero.Humanize(1, minUnit: TimeUnit.Day, toWords: false)); // returns "0 days"
This request is flexible so if there's a better strategy, I'm all for it, :)
Thank you.
I just made a PR that should resolve this issue. https://github.com/Humanizr/Humanizer/pull/732
It looks like this can be closed now. The PR for this issue was merged. 👍
Thank you! :smile:
2.5.1 is live on NuGet now.