@hebcal/core
Version:
A perpetual Jewish Calendar API
56 lines (53 loc) • 2.05 kB
JavaScript
/*! @hebcal/core v5.10.1, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
import { Locale, HDate, months } from '@hebcal/hdate';
import { Event, flags } from './event.js';
import { Molad } from './molad.js';
import './locale.js';
const mevarchimChodeshStr = 'Shabbat Mevarchim Chodesh';
/** Represents Mevarchim haChodesh, the announcement of the new month */
class MevarchimChodeshEvent extends Event {
/**
* Constructs Mevarchim haChodesh event
* @param date Hebrew date event occurs
* @param monthName Hebrew month name (not translated)
* @param [memo]
* @param locale Optional locale name
*/
constructor(date, monthName, memo, locale) {
super(date, `${mevarchimChodeshStr} ${monthName}`, flags.SHABBAT_MEVARCHIM);
this.monthName = Locale.gettext(monthName, locale);
if (memo) {
this.memo = memo;
}
else {
const hyear = date.getFullYear();
const hmonth = date.getMonth();
const monNext = hmonth === HDate.monthsInYear(hyear) ? months.NISAN : hmonth + 1;
const molad = new Molad(hyear, monNext);
this.memo = molad.render('en', { hour12: false });
}
}
basename() {
return this.getDesc();
}
/**
* Returns (translated) description of this event
* @param [locale] Optional locale name (defaults to active locale).
*/
render(locale) {
const monthName0 = Locale.gettext(this.monthName, locale);
const monthName = monthName0.replace(/'/g, '’');
return Locale.gettext(mevarchimChodeshStr, locale) + ' ' + monthName;
}
/**
* Returns (translated) description of this event
* @param [locale] Optional locale name (defaults to active locale).
*/
renderBrief(locale) {
const str = this.render(locale);
const space = str.indexOf(' ');
return str.substring(space + 1);
}
}
export { MevarchimChodeshEvent };
//# sourceMappingURL=MevarchimChodeshEvent.js.map