getPreviousMonthDate function

dynamic getPreviousMonthDate(
  1. dynamic date
)

Returns the previous month start date for the given date.

Implementation

dynamic getPreviousMonthDate(dynamic date) {
  if (date is HijriDateTime) {
    return date.month == 1
        ? HijriDateTime(date.year - 1, 12, 01)
        : HijriDateTime(date.year, date.month - 1, 1);
  }
  return date.month == 1
      ? DateTime(date.year - 1, 12, 1)
      : DateTime(date.year, date.month - 1, 1);
}