I am using Humanizer on a TimeSpan with precision 4:
(dateEnd - dateStart).Humanize(4)
And it generates something like this:
2 hours, 17 minutes, 20 seconds, 141 milliseconds
But when the time remaining is just minutes (less than a hour left) it generates:
17 minutes, 20 seconds, 141 milliseconds, no time
Is there a way to not include this "no time"?
I'm doing this to change the precision based on the run time length:
TimeSpan runTime = dateEnd - dateStart;
if (runTime.TotalMinutes < 1)
{
precision = 1; //49 seconds
}
else if (runTime.TotalHours < 1)
{
precision = 2; //27 minutes, 49 seconds
}
else
{
precision = 3; //1 day, 2 hours, 27 minutes OR 2 hours, 27 minutes, 49 seconds
}
runTime.Humanize(precision);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With