addMonths function

DateTime addMonths(
  1. DateTime date,
  2. int offset
)

Implementation

DateTime addMonths(DateTime date, int offset) {
  int y = date.year;
  int m = date.month;
  int mA = y * 12 + m + offset;

  y = mA ~/ 12;
  m = mA % 12;
  return DateTime(y, m);
}