simlist/pyluach

feature request: Getting specific day of holiday

Closed this issue · 5 comments

Hi.
First, I'd like to say thanks for this great package.

It'd be nice to be able to get the specific day of the holiday. For example "ב סוכות" instead of "סוכות" for all Sukkot days.

I thought about adding that, but I think the different ways people would want it written would be a little much. For now it shouldn't be too hard to implement by subtracting the date from the first day of the holiday and adding one:

from pyluach.dates import HebrewDate
from pyluach.hebrewcal import to_hebrew_numeral
date = HebrewDate(5783, 7, 16)
if date.holiday(hebrew=True) == 'סוכות':
    day = date - HebrewDate(date.year, 7, 15) + 1
    print(f'{to_hebrew_numeral(day)} {date.holiday(hebrew=True)}')

This code supports only Sukkot, and only in Hebrew. Supporting all possible holidays (and even better, both in English and in Hebrew) will be harder...

I suggest ignoring all "the different ways people would want it"; just implement the simplest solution for you - if someone will like it, he can use it, if not, he continue use the existing functions.

jwg4 commented

I would also love to have this feature.

if you add it just in one way, I would be able to work around it

I'll look into adding that to a future version.

Now available in v2.2.0 there is a prefix_day parameter for festival and holiday methods and functions to get the specific day of the holiday. See here and here for some examples.