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

Pirkei Avot for summer Shabbat #435

Closed PupaRebbe closed 3 months ago

PupaRebbe commented 4 months ago

I wrote a function to calculate the Pirkei Avot being studied on Shabbat between Pesach and Rosh Hashana since i didn't find a built-in way to get it. If i post it here does it have a chance to become a part of the project?

mjradwin commented 4 months ago

Thanks! This would be a great addition, and I believe may belong better in the @hebcal/learning package

https://github.com/hebcal/hebcal-learning

Would you like to open a pull request there?

PupaRebbe commented 4 months ago

I am not familiar enough with the Hebcal hierarchy to be able to write it the way it belongs, i also see that all learning schedules of @hebcal/learning are classes while my calculation is written as a simple JS function that takes a parameter and returns a value. That's besides my poor knowledge in node.js and GitHub. Can i post the function here and you will modify/optimize it and merge to the package?

mjradwin commented 4 months ago

Sure, post it here (or post it to https://gist.github.com/ ) and we will work to incorporate it into the learning schedules

PupaRebbe commented 4 months ago

Here it is: https://gist.github.com/PupaRebbe/53b9859514359dc521f63a98f7535e84

mjradwin commented 3 months ago

Thanks! Taking a look at this and will work to incorporate in @hebcal/learning

PupaRebbe commented 3 months ago

@mjradwin well done. was theHebrewCalendar class updated to support Pirkei Avot?

mjradwin commented 3 months ago

Yes, you should be able to use the HebrewCalendar API to get Pirkei Avot as follows (assuming you have the most recent @hebcal/learning version 5.0.8)

import {HebrewCalendar} from '@hebcal/core';
import '@hebcal/learning';

const events = HebrewCalendar.calendar({
  year: 2024,
  noHolidays: true,
  dailyLearning: {
    pirkeiAvotSummer: true,
  },
});

console.log(events);

We did some testing for 5783 and 5784 in both Israel and Diaspora and your algorithm seemed to work really well! We adapted slightly but kept generally the same structure as your code. Let us know if the results looks correct to you!