From 8a06ae5a673dc8ec8639bf17ec23d1c70021a4a6 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Thu, 7 Jan 2021 08:41:45 -0800 Subject: [PATCH] Include Molad details in memo field of MevarchimChodeshEvent --- package.json | 2 +- src/holidays.js | 7 +++++++ src/holidays.spec.js | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c287fa..7a8f343 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hebcal/core", - "version": "3.0.4", + "version": "3.1.0", "author": "Michael J. Radwin (https://github.com/mjradwin)", "contributors": [ "Eyal Schachter (https://github.com/Scimonster)", diff --git a/src/holidays.js b/src/holidays.js index 09b9b1b..bd65247 100644 --- a/src/holidays.js +++ b/src/holidays.js @@ -19,7 +19,9 @@ along with this program. If not, see . */ import {Locale} from './locale'; +import {HDate, months} from './hdate'; import {Event, flags} from './event'; +import {MoladEvent} from './molad'; /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */ export class HolidayEvent extends Event { @@ -116,6 +118,11 @@ export class MevarchimChodeshEvent extends Event { constructor(date, monthName) { super(date, `${mevarchimChodeshStr} ${monthName}`, flags.SHABBAT_MEVARCHIM); this.monthName = monthName; + const hyear = date.getFullYear(); + const hmonth = date.getMonth(); + const monNext = (hmonth == HDate.monthsInYear(hyear) ? months.NISAN : hmonth + 1); + const molad = new MoladEvent(date, hyear, monNext); + this.memo = molad.render(); } /** * Returns (translated) description of this event diff --git a/src/holidays.spec.js b/src/holidays.spec.js index b98ef38..de22ef4 100644 --- a/src/holidays.spec.js +++ b/src/holidays.spec.js @@ -44,6 +44,11 @@ test('basename-and-url', (t) => { t.is(mvch.url(), undefined); }); +test('MevarchimChodeshEvent', (t) => { + const mvch = new MevarchimChodeshEvent(new HDate(23, months.KISLEV, 5769), 'Tevet'); + t.is(mvch.memo, 'Molad Tevet: Sat, 10 minutes and 16 chalakim after 16:00'); +}); + test('shushan-purim', (t) => { const events = HebrewCalendar.calendar({year: 2015, numYears: 15}); const shushan = events.filter((ev) => ev.getDesc() == 'Shushan Purim');