SunnahTimes constructor
SunnahTimes(
- PrayerTimes prayerTimes
Calculate SunnahTimes with PrayerTimes instance.
prayerTimes
a PrayerTimes instance
Implementation
SunnahTimes(PrayerTimes prayerTimes) {
final currentPrayerTimesDate =
CalendarUtil.resolveTimeByDateComponents(prayerTimes.dateComponents);
final tomorrowPrayerTimesDate =
currentPrayerTimesDate.add(Duration(days: 1));
final tomorrowPrayerTimes = PrayerTimes(
prayerTimes.coordinates,
DateComponents.from(tomorrowPrayerTimesDate),
prayerTimes.calculationParameters,
utcOffset: prayerTimes.utcOffset);
final nightDurationInSeconds =
(tomorrowPrayerTimes.fajr.millisecondsSinceEpoch -
prayerTimes.maghrib.millisecondsSinceEpoch) ~/
1000;
_middleOfTheNight = CalendarUtil.roundedMinute(prayerTimes.maghrib
.add(Duration(seconds: nightDurationInSeconds ~/ 2.0)));
_lastThirdOfTheNight = CalendarUtil.roundedMinute(prayerTimes.maghrib.add(
Duration(seconds: (nightDurationInSeconds * (2.0 / 3.0)).toInt())));
}