Produce spoken dates and clock times
Use date ordinal words when a calendar date should read naturally, and clock notation when a TimeOnly value should become a phrase such as “twenty-five past one.” These are localized presentation operations, distinct from relative time and numeric ordinal suffixes.
Example
Date ordinal words use ambient culture. Clock notation can take a culture directly; this executable demonstrates that overload while also scoping both ambient cultures for the date API:
using System.Globalization;
using Humanizer;
var culture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.CurrentCulture = culture;
CultureInfo.CurrentUICulture = culture;
var date = new DateTime(2022, 1, 25).ToOrdinalWords();
var dateInGenitive = new DateOnly(2022, 1, 25).ToOrdinalWords(GrammaticalCase.Genitive);
var time = new TimeOnly(13, 23)
.ToClockNotation(ClockNotationRounding.NearestFiveMinutes, culture);
Console.WriteLine($"Date: {date}");
Console.WriteLine($"Genitive date: {dateInGenitive}");
Console.WriteLine($"Time: {time}");
Date: January 25th, 2022
Genitive date: January 25th, 2022
Time: twenty-five past one
Date ordinal words
DateTime.ToOrdinalWords() and DateOnly.ToOrdinalWords() order the day,
month, and year for CurrentCulture. A GrammaticalCase overload is available
for locales whose date converter supports case-sensitive wording; because date
words have no culture argument, scope CurrentCulture and CurrentUICulture
together at the boundary.
Clock notation
TimeOnly.ToClockNotation() renders the exact minute.
ClockNotationRounding.NearestFiveMinutes first rounds to the nearest
five-minute boundary, then selects the phrase. Rounding can cross an hour or
day-period boundary. The overload that also accepts a CultureInfo
avoids changing ambient culture.
Check culture support
Every culture listed by Configurator.IsCultureSupported supplies date ordinal
words, the grammatical-case overload, and clock notation. A locale whose date
form does not vary by grammatical case returns the same authored date text.
Supported same-language descendants inherit their parent locale's behavior;
no supported non-English culture reaches the English default. Unsupported
cultures can use a configured registry default, so the completeness guarantee
applies only when Configurator.IsCultureSupported returns true.