getPreMonth method

DateTime getPreMonth(
  1. DateTime date
)

获得上个月的DateTime

Implementation

DateTime getPreMonth(DateTime date) {
  int year = date.year;
  int month = date.month;

  month -= 1;
  if (month <= 0) {
    month += 12;
    year -= 1;
  }
  return DateTime(year, month, 1);
}