plus method

FhirTime plus({
  1. int hours = 0,
  2. int minutes = 0,
  3. int seconds = 0,
  4. int milliseconds = 0,
})

Implementation

FhirTime plus(
    {int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0}) {
  int newMilliseconds = (millisecond ?? 0) + milliseconds;
  int newSeconds = (second ?? 0) + seconds + (newMilliseconds ~/ 1000);
  newMilliseconds = newMilliseconds % 1000;
  int newMinutes = (minute ?? 0) + minutes + (newSeconds ~/ 60);
  newSeconds = newSeconds % 60;
  int newHours = (hour ?? 0) + hours + (newMinutes ~/ 60);
  newMinutes = newMinutes % 60;
  newHours = newHours % 24;
  return FhirTime.fromUnits(
    hour: newHours,
    minute: newMinutes,
    second: newSeconds,
    millisecond: newMilliseconds,
  );
}