isTomorrow method
Returns true if this DateTime is the calendar day after now.
Compares date-only (year/month/day), so the time component is irrelevant:
23:59 on the next day still counts as tomorrow. Pass now to pin the
clock for deterministic tests.
DST-safe: tomorrow is found by stepping now's calendar fields, not by
adding 24 elapsed hours, so a 23-hour or 25-hour local day cannot shift
the answer onto the wrong calendar day.
Example:
final now = DateTime(2024, 6, 15);
DateTime(2024, 6, 16).isTomorrow(now: now); // true
DateTime(2024, 6, 15).isTomorrow(now: now); // false
// US Eastern: Nov 1, 2026 is a 25-hour day.
DateTime(2026, 11, 2).isTomorrow(now: DateTime(2026, 11, 1)); // true
Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
bool isTomorrow({DateTime? now}) {
// Bug fix: `now.add(Duration(days: 1))` landed on 23:00 the SAME day from
// midnight of a 25-hour day (and skipped the 23-hour day from late evening).
final DateTime tomorrow = _shiftCalendarDay(now ?? DateTime.now(), 1);
return isSameDateOnly(tomorrow);
}