formatShort static method

String formatShort(
  1. DateTime date, {
  2. String? locale,
  3. DateTime? now,
  4. Duration? max = const Duration(days: 14),
  5. bool withFuture = false,
})

Formats provided date to a fuzzy time like 5m

  • If locale is passed will look for message for that locale, if you want to add or override locales use setLocaleMessages. Defaults to en_short
  • If now is passed this will be the point of reference for calculating the elapsed time. Defaults to DateTime.now()
  • If max is passed, format will only happen between that duration and beyond that simple date format will be shown. To avoid format limits, Pass null. Defaults to 14 days
  • If withFuture is passed, format will use the From prefix. ie. 5m

Implementation

static String formatShort(
  DateTime date, {
  String? locale,
  DateTime? now,
  Duration? max = const Duration(days: 14),
  bool withFuture = false,
}) =>
    format(
      date,
      locale: locale,
      now: now,
      max: max,
      short: true,
      withFuture: withFuture,
    );