isSameMonth method

bool isSameMonth(
  1. DateTime other
)

Returns true if the date is in the same month as other.

Example:

DateTime(2024, 1, 15).isSameMonth(DateTime(2024, 1, 20)); // true

Implementation

bool isSameMonth(DateTime other) {
  return year == other.year && month == other.month;
}