differenceInDays method

int differenceInDays(
  1. DateTime other
)

Difference calculated after omitting hour, minute, ..., microsecond

Does not take timezones of this and other!

Uses DateTime.difference(), therefore behaves same. So, be careful with UTC and local timezones.


If other occured after this, result is negative

today.differenceInDays(tomorrow); // -1
tomorrow.differenceInDays(today); // 1

// 0 means [this] and [other] occured at the same day.

Implementation

int differenceInDays(DateTime other) {
  return date.difference(other.date).inDays;
}