Tuesday, 15 May 2012

c# - How to make Humanizer not display "no time" if the precision is bigger? -



c# - How to make Humanizer not display "no time" if the precision is bigger? -

i using humanizer on timespan precision 4:

(dateend - datestart).humanize(4)

and generates this:

2 hours, 17 minutes, 20 seconds, 141 milliseconds

but when time remaining minutes (less hr left) generates:

17 minutes, 20 seconds, 141 milliseconds, no time

is there way not include "no time"?

i'm doing alter precision based on 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);

c# humanizer

No comments:

Post a Comment