-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.js
29 lines (25 loc) · 966 Bytes
/
core.js
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
import { schedule } from "./calendar.js";
import { adjustTime, getClosestSchedule, isRamadan } from "./util.js";
schedule.year = new Date().getFullYear();
import { districtData } from "./data.js";
function getDistrictAdjustments(districtName) {
const district = districtData.districts.find((d) => d.name === districtName);
return district ? district.adjustments : { suhoor: 0, iftar: 0 };
}
function getAdjustedSchedule(baseSchedule, adjustments) {
const adjusted = { ...baseSchedule };
adjusted.sehri = adjustTime(baseSchedule.sehri, adjustments.suhoor);
adjusted.magrib_iftar = adjustTime(
baseSchedule.magrib_iftar,
adjustments.iftar
);
return adjusted;
}
export const getPrayerTimes = (date, district) => {
const adjustments = getDistrictAdjustments(district);
const baseSchedule = getClosestSchedule(schedule, date);
return {
...getAdjustedSchedule(baseSchedule.schedule, adjustments),
isRamadan: isRamadan(date),
}
};