39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
(function () {
|
|
const dataService = window.TarotDataService || {};
|
|
const {
|
|
DAY_IN_MS,
|
|
toTitleCase,
|
|
getMoonPhaseName,
|
|
getDecanForDate,
|
|
calcPlanetaryHoursForDayAndLocation
|
|
} = window.TarotCalc;
|
|
|
|
const PLANET_CALENDAR_IDS = new Set(["saturn", "jupiter", "mars", "sol", "venus", "mercury", "luna"]);
|
|
const BACKFILL_DAYS = 4;
|
|
const FORECAST_DAYS = 7;
|
|
|
|
function normalizeApiEvent(event) {
|
|
if (!event || typeof event !== "object") {
|
|
return event;
|
|
}
|
|
|
|
return {
|
|
...event,
|
|
start: event.start ? new Date(event.start) : event.start,
|
|
end: event.end ? new Date(event.end) : event.end
|
|
};
|
|
}
|
|
|
|
async function buildWeekEvents(geo, referenceData, anchorDate) {
|
|
const payload = await dataService.fetchWeekEvents?.(geo, anchorDate);
|
|
const events = Array.isArray(payload?.events)
|
|
? payload.events
|
|
: (Array.isArray(payload) ? payload : []);
|
|
return events.map((event) => normalizeApiEvent(event));
|
|
}
|
|
|
|
window.TarotEventBuilder = {
|
|
buildWeekEvents
|
|
};
|
|
})();
|