humanize library

Support for doing something awesome.

More dartdocs go here.

Classes

Awesome
Checks if you are awesome. Spoiler: you are.
CompositeFilter
Chains multiple string filters together.
DateTimeLocale
HumanDateFormat
Preset formats inspired by Luxon.
HumanizeI18n
Thin, locale-aware facade over humanize helpers.
LocalizedDateTime
SimpleLocale
Minimal locale utilities for natural text.
StringFilter
A simple interface for string filters.

Extensions

DateTimeCalendarMath on DateTime
DateTimeFormatting on DateTime
DateTime formatting helpers and an extension for convenient calls.
DateTimeLocalized on DateTime
ToLocaleString on DateTime

Functions

apNumber(int n, {String locale = 'en'}) String
AP style numbers: spell out 1-9, otherwise return digits. Supports basic locales: 'en' (default) and 'fr'.
calendarAddMonths(DateTime dt, int months) DateTime
calendarAddYears(DateTime dt, int years) DateTime
capfirst(String s) String
Capitalize the first letter of the string.
dateTimeLocaleFor(String code) DateTimeLocale
filesizeformat(num bytes, {int precision = 1}) String
Format bytes into human-readable units.
intcomma(num value, {String sep = ','}) String
Format a number with thousand separators in the integer part. Keeps the fractional part as-is if present (e.g., 4500.2 -> 4,500.2).
intword(num n, {int precision = 1, bool short = false, String locale = 'en'}) String
Human-friendly representation for large numbers.
naturalday(DateTime date, {DateTime? now, String locale = 'en', String format = 'yyyy-MM-dd'}) String
Natural day labeling: today, tomorrow, yesterday; otherwise formatted date. Supports locales 'en' and 'fr'. Basic formatting tokens: yyyy, MM, dd, MMM, MMMM.
naturaldelta(Duration delta, {String locale = 'en'}) String
Describe a Duration in natural language, e.g. "3 days" or "2 hours".
naturalJoin(List<String> items, {String locale = 'en', String delimiter = ', ', String lastDelimiterEn = ' and ', String lastDelimiterFr = ' et '}) String
Natural join with configurable separators.
naturaltime(DateTime moment, {DateTime? now, String locale = 'en'}) String
Human readable relative time, e.g. "3 minutes ago" or "in 2 hours". For differences over a day, combines units (e.g., "1 week, 2 days").
ordinal(int n, {String locale = 'en'}) String
Convert integer to ordinal string. en: 1 -> 1st, 2 -> 2nd; fr: 1 -> 1er, others -> 2e, 3e ...
oxfordComma(List<String> items, {String locale = 'en'}) String
Join items using an Oxford comma in English, and no serial comma in French.
titlecase(String s) String
Convert a string to Title Case (basic implementation).
truncatechars(String s, int max, {String ellipsis = '...'}) String
Truncate to at most max characters, adding ellipsis if truncated.
truncatewords(String s, int maxWords, {String ellipsis = '...'}) String
Truncate to at most maxWords words, adding ellipsis if truncated.

Typedefs

Filter<T> = T Function(T value)