Пример #1
0
def get_next_rosh_chodesh(date_: date = None) -> RoshChodesh:
    calendar = JewishCalendar(date_ or dt.now())

    if calendar.is_rosh_chodesh():
        return get_next_rosh_chodesh(date_ + timedelta(days=-1))

    if calendar.jewish_month == 6:
        return get_next_rosh_chodesh(date_ + timedelta(
            days=calendar.days_in_jewish_month()))

    month_length = calendar.days_in_jewish_month()
    days_until_rh = 30 - calendar.jewish_day
    calendar.forward(days_until_rh)

    rh_dates = [calendar.gregorian_date.isoformat()]
    if month_length == 30:
        rh_dates.append(calendar.forward().gregorian_date.isoformat())

    molad = calendar.molad()
    molad_iso = dt(molad.gregorian_year, molad.gregorian_month,
                   molad.gregorian_day, molad.molad_hours, molad.molad_minutes)

    rh_data = {
        'month_name': calendar.jewish_month_name(),
        'days': rh_dates,
        'duration': 1 if month_length == 29 else 2,
        'molad': [molad_iso, molad.molad_chalakim]
    }
    settings = SimpleSettings(date=date_ or dt.now())
    return RoshChodesh(settings=settings, **rh_data)
Пример #2
0
def all_days_matching(year,
                      matcher,
                      in_israel=False,
                      use_modern_holidays=False):
    calendar = JewishCalendar(year, 7, 1)
    calendar.in_israel = in_israel
    calendar.use_modern_holidays = use_modern_holidays
    collection = {}
    while calendar.jewish_year == year:
        sd = matcher(calendar)
        if sd:
            if sd not in collection:
                collection[sd] = []
            collection[sd] += [
                f'{calendar.jewish_month}-{calendar.jewish_day}'
            ]
        calendar.forward()
    return collection
 def find_day(c: JewishCalendar):
     found_days.append(c.day_of_omer())
     c.forward()