Skip to content

Commit

Permalink
Resolve merge conflicts as part of #475
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 4, 2024
1 parent 5707fc8 commit 9299b90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 45 deletions.
16 changes: 2 additions & 14 deletions src/hebcal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}

/**
Expand Down
33 changes: 2 additions & 31 deletions src/holidays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9299b90

Please sign in to comment.