Skip to main content
Version: 3.0.8

Humanizer.IFormatter

IFormatter Interface

Implement this interface if your language has complex rules around dealing with numbers. For example in Romanian "5 days" is "5 zile", while "24 days" is "24 de zile" and in Arabic 2 days is يومين not 2 يوم

public interface IFormatter

Derived
DefaultFormatter

Methods

IFormatter.DataUnitHumanize(DataUnit, double, bool) Method

Returns the string representation of the provided DataUnit, either as a symbol or full word

string DataUnitHumanize(Humanizer.DataUnit dataUnit, double count, bool toSymbol=true);

Parameters

dataUnit DataUnit

Data unit

count System.Double

Number of said units, to adjust for singular/plural forms

toSymbol System.Boolean

Indicates whether the data unit should be expressed as symbol or full word

Returns

System.String
String representation of the provided DataUnit

IFormatter.DateHumanize(TimeUnit, Tense, int) Method

Returns the string representation of the provided DateTime

string DateHumanize(Humanizer.TimeUnit timeUnit, Humanizer.Tense timeUnitTense, int unit);

Parameters

timeUnit TimeUnit

timeUnitTense Tense

unit System.Int32

Returns

System.String

IFormatter.DateHumanize_Never() Method

string DateHumanize_Never();

Returns

System.String

IFormatter.DateHumanize_Now() Method

string DateHumanize_Now();

Returns

System.String

IFormatter.TimeSpanHumanize(TimeUnit, int, bool) Method

Returns the string representation of the provided TimeSpan

string TimeSpanHumanize(Humanizer.TimeUnit timeUnit, int unit, bool toWords=false);

Parameters

timeUnit TimeUnit

unit System.Int32

toWords System.Boolean

Returns

System.String

IFormatter.TimeSpanHumanize_Age() Method

Returns the age format that converts a humanized TimeSpan string to an age expression. For instance, in English that format adds the " old" suffix, so that "40 years" becomes "40 years old".

string TimeSpanHumanize_Age();

Returns

System.String
Age format

IFormatter.TimeSpanHumanize_Zero() Method

0 seconds

string TimeSpanHumanize_Zero();

Returns

System.String
Returns 0 seconds as the string representation of Zero TimeSpan

IFormatter.TimeUnitHumanize(TimeUnit) Method

Returns the symbol for the given TimeUnit

string TimeUnitHumanize(Humanizer.TimeUnit timeUnit);

Parameters

timeUnit TimeUnit

Time unit

Returns

System.String
String representation of the provided TimeUnit