Humanizer.TimeSpanHumanizeExtensions
TimeSpanHumanizeExtensions Class
Humanizes TimeSpan into human readable form
public static class TimeSpanHumanizeExtensions
Inheritance System.Object → TimeSpanHumanizeExtensions
Methods
TimeSpanHumanizeExtensions.Humanize(this TimeSpan, int, bool, CultureInfo, TimeUnit, TimeUnit, string, bool) Method
Turns a TimeSpan into a human readable form. E.g. 1 day.
public static string Humanize(this System.TimeSpan timeSpan, int precision, bool countEmptyUnits, System.Globalization.CultureInfo culture=null, Humanizer.Localisation.TimeUnit maxUnit=Humanizer.Localisation.TimeUnit.Week, Humanizer.Localisation.TimeUnit minUnit=Humanizer.Localisation.TimeUnit.Millisecond, string collectionSeparator=", ", bool toWords=false);
Parameters
timeSpan System.TimeSpan
precision System.Int32
The maximum number of time units to return.
countEmptyUnits System.Boolean
Controls whether empty time units should be counted towards maximum number of time units. Leading empty time units never count.
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
maxUnit TimeUnit
The maximum unit of time to output. The default value is Week. The time units Month and Year will give approximations for time spans bigger than 30 days by calculating with 365.2425 days a year and 30.4369 days a month.
minUnit TimeUnit
The minimum unit of time to output.
collectionSeparator System.String
The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used.
toWords System.Boolean
Uses words instead of numbers if true. E.g. one day.
Returns
TimeSpanHumanizeExtensions.Humanize(this TimeSpan, int, CultureInfo, TimeUnit, TimeUnit, string, bool) Method
Turns a TimeSpan into a human readable form. E.g. 1 day.
public static string Humanize(this System.TimeSpan timeSpan, int precision=1, System.Globalization.CultureInfo culture=null, Humanizer.Localisation.TimeUnit maxUnit=Humanizer.Localisation.TimeUnit.Week, Humanizer.Localisation.TimeUnit minUnit=Humanizer.Localisation.TimeUnit.Millisecond, string collectionSeparator=", ", bool toWords=false);
Parameters
timeSpan System.TimeSpan
precision System.Int32
The maximum number of time units to return. Defaulted is 1 which means the largest unit is returned
culture System.Globalization.CultureInfo
Culture to use. If null, current thread's UI culture is used.
maxUnit TimeUnit
The maximum unit of time to output. The default value is Week. The time units Month and Year will give approximations for time spans bigger 30 days by calculating with 365.2425 days a year and 30.4369 days a month.
minUnit TimeUnit
The minimum unit of time to output.
collectionSeparator System.String
The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used.
toWords System.Boolean
Uses words instead of numbers if true. E.g. one day.