addHours method

Jalali addHours(
  1. int hours
)

Adds the specified number of hours to the current Jalali date.

Implementation

Jalali addHours(int hours) {
  // Calculate the new hour and the number of days to add if the hour overflows
  int newHour = (hour + hours) % 24;
  int dayOverflow = (hour + hours) ~/ 24;

  // Create a new Jalali date with the updated hour and adjusted day
  Jalali newDateTime = copyWith(
    hour: newHour,
  );

  return dayOverflow > 0 ? newDateTime.addDays(dayOverflow) : newDateTime;
}