firstDayOfNextMonth static method

DateTime firstDayOfNextMonth(
  1. DateTime dateTime
)

Returns DateTime that represents a beginning of the first day of the next month.

Example: (2020, 4, 9, 15, 16) -> (2020, 5, 1, 0, 0, 0, 0).

Implementation

static DateTime firstDayOfNextMonth(DateTime dateTime) {
  final month = dateTime.month;
  final year = dateTime.year;
  final nextMonthStart = (month < DateTime.monthsPerYear)
      ? _date(dateTime.isUtc, year, month + 1, 1)
      : _date(dateTime.isUtc, year + 1, 1, 1);
  return nextMonthStart;
}