forked from batoulapps/adhan-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSunnahTimes.ts
32 lines (28 loc) · 857 Bytes
/
SunnahTimes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import {
dateByAddingDays,
dateByAddingSeconds,
roundedMinute,
} from './DateUtils';
import PrayerTimes from './PrayerTimes';
export default class SunnahTimes {
middleOfTheNight: Date;
lastThirdOfTheNight: Date;
constructor(prayerTimes: PrayerTimes) {
const date = prayerTimes.date;
const nextDay = dateByAddingDays(date, 1);
const nextDayPrayerTimes = new PrayerTimes(
prayerTimes.coordinates,
nextDay,
prayerTimes.calculationParameters,
);
const nightDuration =
(nextDayPrayerTimes.fajr.getTime() - prayerTimes.maghrib.getTime()) /
1000.0;
this.middleOfTheNight = roundedMinute(
dateByAddingSeconds(prayerTimes.maghrib, nightDuration / 2),
);
this.lastThirdOfTheNight = roundedMinute(
dateByAddingSeconds(prayerTimes.maghrib, nightDuration * (2 / 3)),
);
}
}