Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

Add explicit option to return "0 seconds" instead of "no time"

Open icnocop opened this issue 8 years ago • 6 comments

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?

icnocop avatar Jun 21 '18 21:06 icnocop

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?

wcsanders1 avatar Jul 08 '18 22:07 wcsanders1

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.

icnocop avatar Jul 08 '18 22:07 icnocop

I just made a PR that should resolve this issue. https://github.com/Humanizr/Humanizer/pull/732

wcsanders1 avatar Jul 21 '18 21:07 wcsanders1

It looks like this can be closed now. The PR for this issue was merged. 👍

lauren-van-sloun avatar Sep 17 '18 16:09 lauren-van-sloun

Thank you! :smile:

icnocop avatar Sep 17 '18 17:09 icnocop

2.5.1 is live on NuGet now.

clairernovotny avatar Sep 17 '18 17:09 clairernovotny