nextMonth static method

DateTime nextMonth(
  1. DateTime date
)

Returns same date in the next month as a DateTime.

与 nextDay/previousDay/nextYear/previousYear 保持一致返回 DateTime。月末溢出时按下月末日收敛(委托 addMonths,例如 1-31 → 2-28)。

BREAKING: 旧实现返回 int(仅月份编号 1-12)。如需旧的月份编号请用 date.month == 12 ? 1 : date.month + 1。

Implementation

static DateTime nextMonth(DateTime date) => addMonths(date, 1);