hebcal / hebcal-es6

perpetual Jewish Calendar with holidays, Shabbat and holiday candle lighting and havdalah times, Torah readings, and more
https://hebcal.github.io/api/core/
GNU General Public License v2.0
98 stars 14 forks source link

Is there a way to get parsha and even info? #414

Closed isaacfink closed 4 months ago

isaacfink commented 5 months ago

For example I want a way to get the following string (in hebrew)

parshas vayijra shabbos chol hamoed

I had this exact functionality at some point with a single function without constructing the string myself, but I don't remember how I did it

mjradwin commented 5 months ago

For a given Saturday, you can get all of the events on the date and then render them as Hebrew using something like the following:

import {HebrewCalendar, HDate} from '@hebcal/core';

const saturday = new Date(2024, 3, 6); // 2024-04-06
const hd = new HDate(saturday);
const events = HebrewCalendar.calendar({
  start: hd,
  end: hd,
  sedrot: true,
});

const strs = events.map((ev) => ev.render('he'));
const str = strs.join(' ');
console.log(str); // 'שַׁבָּת הַחֹדֶשׁ פָּרָשַׁת שְּׁמִינִי'