@hebcal/core
Version:
A perpetual Jewish Calendar API
49 lines (46 loc) • 1.53 kB
JavaScript
/*! @hebcal/core v6.0.8, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
import { Event, flags } from './event.js';
import { isoDateString } from '@hebcal/hdate';
import { renderParshaName } from './parshaName.js';
import './locale.js';
/**
* Represents one of 54 weekly Torah portions, always on a Saturday
*/
class ParshaEvent extends Event {
constructor(parsha) {
const desc = 'Parashat ' + parsha.parsha.join('-');
super(parsha.hdate, desc, flags.PARSHA_HASHAVUA);
this.p = parsha;
}
/**
* @param [locale] Optional locale name (i.e: `'he'`, `'fr'`). Defaults to empty locale.
*/
render(locale) {
return renderParshaName(this.p.parsha, locale);
}
basename() {
return this.p.parsha.join('-');
}
url() {
const year = this.greg().getFullYear();
if (year < 100 || year > 2999) {
return undefined;
}
const dt = this.urlDateSuffix();
const url = 'https://www.hebcal.com/sedrot/' +
this.basename().toLowerCase().replace(/'/g, '').replace(/ /g, '-') +
'-' +
dt;
return this.p.il ? url + '?i=on' : url;
}
urlDateSuffix() {
const isoDate = isoDateString(this.greg());
return isoDate.replace(/-/g, '');
}
/** convenience function for compatibility with previous implementation */
get parsha() {
return this.p.parsha;
}
}
export { ParshaEvent };
//# sourceMappingURL=ParshaEvent.js.map