isSameMonth method

bool isSameMonth(
  1. DateTime other
)

Checks if two DateTime instances are in the same month and year.

Example usage:

final date1 = DateTime(2020, 1, 1);
final date2 = DateTime(2020, 1, 15);
print(date1.isSameMonth(date2)); // true

Implementation

bool isSameMonth(DateTime other) => other.year == year && other.month == month;