Provides the standard formatter implementation for Humanizer locales.
public class DefaultFormatter : Humanizer.IGrammaticalCaseTimeSpanFormatter, Humanizer.IFormatterInheritance System.Object → DefaultFormatter
Implements IGrammaticalCaseTimeSpanFormatter, IFormatter
Initializes a new formatter for the specified locale code.
public DefaultFormatter(string localeCode);localeCode System.String
The locale code used to construct the formatter culture.
Initializes a new formatter for the specified culture.
public DefaultFormatter(System.Globalization.CultureInfo culture);culture System.Globalization.CultureInfo
The culture used to resolve resources and localized number words.
Gets the culture used to resolve resources and localized number words.
protected System.Globalization.CultureInfo Culture { protected get; }System.Globalization.CultureInfo
Returns the localized representation of a data unit, either as a symbol or a full word.
public virtual string DataUnitHumanize(Humanizer.DataUnit dataUnit, double count, bool toSymbol=true);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.
Implements DataUnitHumanize(DataUnit, double, bool)
System.String
The localized data-unit representation.
System.ArgumentOutOfRangeException
If dataUnit is unsupported.
Returns the localized representation of a relative date phrase.
public virtual string DateHumanize(Humanizer.TimeUnit timeUnit, Humanizer.Tense timeUnitTense, int unit);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.
Implements DateHumanize(TimeUnit, Tense, int)
System.String
The localized relative date phrase.
System.ArgumentOutOfRangeException
If timeUnit is unsupported or unit is negative.
Returns the localized text used when a date never occurs.
public virtual string DateHumanize_Never();Implements DateHumanize_Never()
Returns the localized text for the current moment.
public virtual string DateHumanize_Now();Implements DateHumanize_Now()
Converts a number to words for the current culture.
protected virtual string NumberToWords(Humanizer.TimeUnit unit, int number, System.Globalization.CultureInfo culture);unit TimeUnit
The unit being formatted.
number System.Int32
The numeric value to convert.
culture System.Globalization.CultureInfo
The culture to use when generating the words.
System.String
The number rendered as words for the configured culture.
Returns the localized representation of a duration.
public virtual string TimeSpanHumanize(Humanizer.TimeUnit timeUnit, int unit, bool toWords=false);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.
Implements TimeSpanHumanize(TimeUnit, int, bool)
System.String
The localized duration phrase.
System.ArgumentOutOfRangeException
If timeUnit is unsupported or unit is negative.
Returns the localized representation of a non-negative seconds value.
public virtual string TimeSpanHumanizeWithFractionalSeconds(decimal seconds, bool toSymbols);seconds System.Decimal
The non-negative seconds value to format.
toSymbols System.Boolean
Whether the seconds unit is rendered as a symbol.
System.String
The localized seconds value.
Returns the localized age suffix format for a humanized duration.
public virtual string TimeSpanHumanize_Age();Implements TimeSpanHumanize_Age()
System.String
The localized age suffix format.
Returns the localized representation of a zero-length duration.
public virtual string TimeSpanHumanize_Zero();Implements TimeSpanHumanize_Zero()
System.String
The localized zero-duration phrase.
Returns the localized symbol for the given TimeUnit.
public virtual string TimeUnitHumanize(Humanizer.TimeUnit timeUnit);timeUnit TimeUnit
The time unit to format.
Implements TimeUnitHumanize(TimeUnit)
System.String
The localized symbol for timeUnit.
System.ArgumentOutOfRangeException
If timeUnit is unsupported.
string Humanizer.IGrammaticalCaseTimeSpanFormatter.TimeSpanHumanize(Humanizer.TimeUnit timeUnit, int unit, Humanizer.GrammaticalCase grammaticalCase);timeUnit TimeUnit
unit System.Int32
grammaticalCase GrammaticalCase