reduceDaysAndSetHHMM static method

DateTime reduceDaysAndSetHHMM(
  1. DateTime ref,
  2. int days,
  3. String hhColonMM
)

Subtracts days from a reference date and sets the time to the specified HH:MM.

Parameters:

  • ref: Reference DateTime
  • days: Number of days to subtract
  • hhColonMM: Time in "HH:MM" format

Returns a new DateTime with subtracted days and specified time (seconds and milliseconds set to 0).

Implementation

static DateTime reduceDaysAndSetHHMM(
    DateTime ref, int days, String hhColonMM) {
  var timeOfDay = parseHHColonMMToTimeOfDay(hhColonMM);
  return ref.subtract(Duration(days: days)).copyWith(
      hour: timeOfDay.hour,
      minute: timeOfDay.minute,
      second: 0,
      millisecond: 0);
}