isSameDay method

bool isSameDay(
  1. DateTime other, {
  2. bool ignoreTime = true,
  3. bool ignoreTimezone = true,
})

Return if date is the same day as other

other - date to compare

ignoreTime - if true, time will be ignored

ignoreTimezone - if true, timezone will be ignored

Implementation

bool isSameDay(DateTime other,
    {bool ignoreTime = true, bool ignoreTimezone = true}) {
  if (ignoreTimezone) {
    return year == other.year &&
        month == other.month &&
        day == other.day &&
        (ignoreTime ||
            (hour == other.hour &&
                minute == other.minute &&
                second == other.second &&
                millisecond == other.millisecond &&
                microsecond == other.microsecond));
  } else {
    return year == other.year &&
        month == other.month &&
        day == other.day &&
        (ignoreTime ||
            (hour == other.hour &&
                minute == other.minute &&
                second == other.second &&
                millisecond == other.millisecond &&
                microsecond == other.microsecond &&
                timeZoneOffset == other.timeZoneOffset));
  }
}