isSameMonth method

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

Return if date is the same month as other

other - date to compare

ignoreTime - if true, time will be ignored

ignoreTimezone - if true, timezone will be ignored

ignoreDay - if true, day will be ignored

Implementation

bool isSameMonth(DateTime other,
    {bool ignoreTime = true,
    bool ignoreTimezone = true,
    bool ignoreDay = true}) {
  if (ignoreTimezone) {
    return year == other.year &&
        month == other.month &&
        (ignoreDay || 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 &&
        (ignoreDay || day == other.day) &&
        (ignoreTime ||
            (hour == other.hour &&
                minute == other.minute &&
                second == other.second &&
                millisecond == other.millisecond &&
                microsecond == other.microsecond &&
                timeZoneOffset == other.timeZoneOffset));
  }
}