getDateTimeThisMonth function

Pair<DateTime> getDateTimeThisMonth([
  1. DateTime? time
])

Returns start and end of this month, using time as reference.

time if null uses DateTime.now .

Implementation

Pair<DateTime> getDateTimeThisMonth([DateTime? time]) {
  time ??= DateTime.now();

  var y = time.year;
  var m = time.month;
  return Pair(
      getDateTimeDayStart(DateTime(y, m, 1, 0, 0, 0, 0, 0)),
      getDateTimeDayEnd(
          DateTime(y, m, getLastDayOfMonth(m, year: y), 23, 59, 59, 0, 0)));
}