getDaysInMouth static method

int getDaysInMouth({
  1. DateTime? dateTime,
  2. int? year,
  3. int? month,
})

返回当前月份的自然月天数

Implementation

static int getDaysInMouth({DateTime? dateTime, int? year, int? month}) {
  if (dateTime == null && (year == null || month == null)) {
    return 30;
  }
  return DateTime(year ?? dateTime!.year, (month ?? dateTime!.month) + 1, 1)
      .add(const Duration(days: -1))
      .day;
}