Skip to main content
Version: 2.10.1

Humanizer.DateHumanizeExtensions

DateHumanizeExtensions Class​

Humanizes DateTime into human readable sentence

public static class DateHumanizeExtensions

Inheritance System.Object → DateHumanizeExtensions

Methods​

DateHumanizeExtensions.Humanize(this DateTime, Nullable<bool>, Nullable<DateTime>, CultureInfo) Method​

Turns the current or provided date into a human readable sentence

public static string Humanize(this System.DateTime input, System.Nullable<bool> utcDate=null, System.Nullable<System.DateTime> dateToCompareAgainst=null, System.Globalization.CultureInfo culture=null);

Parameters​

input System.DateTime

The date to be humanized

utcDate System.Nullable<System.Boolean>

Nullable boolean value indicating whether the date is in UTC or local. If null, current date is used with the same DateTimeKind of input

dateToCompareAgainst System.Nullable<System.DateTime>

Date to compare the input against. If null, current date is used as base

culture System.Globalization.CultureInfo

Culture to use. If null, current thread's UI culture is used.

Returns​

System.String
distance of time in words

DateHumanizeExtensions.Humanize(this DateTimeOffset, Nullable<DateTimeOffset>, CultureInfo) Method​

Turns the current or provided date into a human readable sentence

public static string Humanize(this System.DateTimeOffset input, System.Nullable<System.DateTimeOffset> dateToCompareAgainst=null, System.Globalization.CultureInfo culture=null);

Parameters​

input System.DateTimeOffset

The date to be humanized

dateToCompareAgainst System.Nullable<System.DateTimeOffset>

Date to compare the input against. If null, current date is used as base

culture System.Globalization.CultureInfo

Culture to use. If null, current thread's UI culture is used.

Returns​

System.String
distance of time in words

DateHumanizeExtensions.Humanize(this Nullable<DateTime>, Nullable<bool>, Nullable<DateTime>, CultureInfo) Method​

Turns the current or provided date into a human readable sentence, overload for the nullable DateTime, returning 'never' in case null

public static string Humanize(this System.Nullable<System.DateTime> input, System.Nullable<bool> utcDate=null, System.Nullable<System.DateTime> dateToCompareAgainst=null, System.Globalization.CultureInfo culture=null);

Parameters​

input System.Nullable<System.DateTime>

The date to be humanized

utcDate System.Nullable<System.Boolean>

Nullable boolean value indicating whether the date is in UTC or local. If null, current date is used with the same DateTimeKind of input

dateToCompareAgainst System.Nullable<System.DateTime>

Date to compare the input against. If null, current date is used as base

culture System.Globalization.CultureInfo

Culture to use. If null, current thread's UI culture is used.

Returns​

System.String
distance of time in words

DateHumanizeExtensions.Humanize(this Nullable<DateTimeOffset>, Nullable<DateTimeOffset>, CultureInfo) Method​

Turns the current or provided date into a human readable sentence, overload for the nullable DateTimeOffset, returning 'never' in case null

public static string Humanize(this System.Nullable<System.DateTimeOffset> input, System.Nullable<System.DateTimeOffset> dateToCompareAgainst=null, System.Globalization.CultureInfo culture=null);

Parameters​

input System.Nullable<System.DateTimeOffset>

The date to be humanized

dateToCompareAgainst System.Nullable<System.DateTimeOffset>

Date to compare the input against. If null, current date is used as base

culture System.Globalization.CultureInfo

Culture to use. If null, current thread's UI culture is used.

Returns​

System.String
distance of time in words