removeDays method

DateTime removeDays(
  1. int days
)

Remove days from the current date without taking into account the different daylight

Implementation

DateTime removeDays(int days) {
  // Create a new DateTime by directly subtracting days and let Dart handle month/year underflow
  final newDate = DateTime(year, month, day - days);

  // Ensure the result has a time of 00:00:00 (midnight)
  return DateTime(newDate.year, newDate.month, newDate.day);
}