getSimpleRelativeDay method
Returns the SimpleRelativeDay bucket for this date relative to now.
now defaults to DateTime.now when omitted. Returns null when the
date is outside the classifiable ~2-month window (same calendar month but
beyond ±2 weeks, or more than one calendar month away) — there is no
useful single relative label for such dates.
Time-of-day is dropped, so the result reflects calendar days. Pass now
and the receiver as the same UTC/local kind: a kind mismatch shifts the
day delta by the zone offset and can misbucket a boundary date.
Example:
final DateTime now = DateTime(2024, 12, 29);
DateTime(2024, 12, 28).getSimpleRelativeDay(now: now); // yesterday
DateTime(2024, 11, 15).getSimpleRelativeDay(now: now); // lastMonth
DateTime(2025, 3, 15).getSimpleRelativeDay(now: now); // null
Audited: 2026-06-12 11:26 EDT
Implementation
SimpleRelativeDay? getSimpleRelativeDay({DateTime? now}) => getRelativeDayResult(now: now)?.type;