Skip to main content
Version: 4.0 (next)

Humanizer.IFormatter

IFormatter Interface

Localizes Humanizer's number, date, duration, and unit formatting.

public interface IFormatter

Derived
DefaultFormatter
IGrammaticalCaseTimeSpanFormatter

Methods

IFormatter.DataUnitHumanize(DataUnit, double, bool) Method

Returns the localized representation of a data unit, either as a symbol or a full word.

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

Parameters

dataUnit DataUnit

The data unit to format.

count System.Double

The number of units being described.

toSymbol System.Boolean

Whether the unit should be rendered as a symbol.

Returns

System.String
The localized data-unit representation.

Exceptions

System.ArgumentOutOfRangeException
If dataUnit is unsupported.

IFormatter.DateHumanize(TimeUnit, Tense, int) Method

Returns the localized representation of a relative date phrase.

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

Parameters

timeUnit TimeUnit

The unit being described.

timeUnitTense Tense

Whether the reference is in the past or the future.

unit System.Int32

The number of units being described.

Returns

System.String
The localized relative date phrase.

Exceptions

System.ArgumentOutOfRangeException
If timeUnit is unsupported or unit is negative.

IFormatter.DateHumanize_Never() Method

Returns the localized text used when a date never occurs.

string DateHumanize_Never();

Returns

System.String

IFormatter.DateHumanize_Now() Method

Returns the localized text for the current moment.

string DateHumanize_Now();

Returns

System.String

IFormatter.TimeSpanHumanize(TimeUnit, int, bool) Method

Returns the localized representation of a duration.

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

Parameters

timeUnit TimeUnit

The unit being described.

unit System.Int32

The number of units being described.

toWords System.Boolean

Whether the number should be rendered as words.

Returns

System.String
The localized duration phrase.

Exceptions

System.ArgumentOutOfRangeException
If timeUnit is unsupported or unit is negative.

IFormatter.TimeSpanHumanize_Age() Method

Returns the localized age suffix format for a humanized duration.

string TimeSpanHumanize_Age();

Returns

System.String
The localized age suffix format.

IFormatter.TimeSpanHumanize_Zero() Method

Returns the localized representation of a zero-length duration.

string TimeSpanHumanize_Zero();

Returns

System.String
The localized zero-duration phrase.

IFormatter.TimeUnitHumanize(TimeUnit) Method

Returns the localized symbol for the given TimeUnit.

string TimeUnitHumanize(Humanizer.TimeUnit timeUnit);

Parameters

timeUnit TimeUnit

The time unit to format.

Returns

System.String
The localized symbol for timeUnit.

Exceptions

System.ArgumentOutOfRangeException
If timeUnit is unsupported.