From 9299b905537d83b1e4be2b6e027e04599caba333 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Sun, 3 Nov 2024 16:09:07 -0800 Subject: [PATCH] Resolve merge conflicts as part of #475 --- src/hebcal.ts | 16 ++-------------- src/holidays.ts | 33 ++------------------------------- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/src/hebcal.ts b/src/hebcal.ts index df76b64..6c1a3e0 100644 --- a/src/hebcal.ts +++ b/src/hebcal.ts @@ -28,8 +28,8 @@ import {Sedra, getSedra} from './sedra'; import {hallel_} from './hallel'; import { getHolidaysForYear_, + getHolidaysForYearArray, getHolidaysOnDate, - holidayFilter, HolidayYearMap, } from './holidays'; import {HolidayEvent} from './HolidayEvent'; @@ -251,19 +251,7 @@ export class HebrewCalendar { * @param il use the Israeli schedule for holidays */ static getHolidaysForYearArray(year: number, il: boolean): HolidayEvent[] { - const yearMap = getHolidaysForYear_(year); - const startAbs = HDate.hebrew2abs(year, months.TISHREI, 1); - const endAbs = HDate.hebrew2abs(year + 1, months.TISHREI, 1) - 1; - let events: HolidayEvent[] = []; - for (let absDt = startAbs; absDt <= endAbs; absDt++) { - const hd = new HDate(absDt); - const holidays = yearMap.get(hd.toString()); - if (holidays) { - const filtered: HolidayEvent[] = holidays.filter(holidayFilter(il)); - events = events.concat(filtered); - } - } - return events; + return getHolidaysForYearArray(year, il); } /** diff --git a/src/holidays.ts b/src/holidays.ts index 9fcf936..55a6651 100644 --- a/src/holidays.ts +++ b/src/holidays.ts @@ -45,8 +45,9 @@ function observedInIsrael(ev: Event): boolean { function observedInDiaspora(ev: Event): boolean { return ev.observedInDiaspora(); } + /** @private */ -export function holidayFilter(il: boolean) { +function holidayFilter(il: boolean) { return il ? observedInIsrael : observedInDiaspora; } @@ -461,36 +462,6 @@ function getBirkatHaChama(year: number): number { return 0; } -function observedInIsrael(ev: HolidayEvent): boolean { - return ev.observedInIsrael(); -} - -function observedInDiaspora(ev: HolidayEvent): boolean { - return ev.observedInDiaspora(); -} - -/** - * Returns an array of Events on this date (or `undefined` if no events) - * @param date Hebrew Date, Gregorian date, or absolute R.D. day number - * @param [il] use the Israeli schedule for holidays - */ -export function getHolidaysOnDate( - date: HDate | Date | number, - il?: boolean -): HolidayEvent[] | undefined { - const hd = HDate.isHDate(date) ? (date as HDate) : new HDate(date); - const hdStr = hd.toString(); - const yearMap = getHolidaysForYear_(hd.getFullYear()); - const events = yearMap.get(hdStr); - // if il isn't a boolean return both diaspora + IL for day - if (typeof il === 'undefined' || typeof events === 'undefined') { - return events; - } - const myFilter = il ? observedInIsrael : observedInDiaspora; - const filtered = events.filter(myFilter); - return filtered; -} - /** * Returns an array of holidays for the year * @param year Hebrew year