def compose_msg(lang: str) -> str:
    jcalendar = JewishCalendar.from_date(date.today()).forward(1)
    omer_day = jcalendar.day_of_omer()
    if not omer_day:
        raise ValueError('No omer day!')

    if jcalendar.gregorian_date.weekday() != 5:
        msg = texsts.MESSAGES[lang]
    else:
        msg = texsts.MESSAGES_FRIDAY[lang]

    if lang == 'en':
        if omer_day % 10 == 1:
            omer_day = f'{omer_day}st'
        elif omer_day % 10 == 2:
            omer_day = f'{omer_day}nd'
        elif omer_day % 10 == 3:
            omer_day = f'{omer_day}rd'
        else:
            omer_day = f'{omer_day}th'
    elif lang == 'ru':
        omer_day = f'{omer_day}-й'

    msg = msg.format(f'<b>{omer_day}</b>')
    full_text = f'{msg}\n\n' \
                f'<code>{texsts.blessing}\n\n' \
                f'{texsts.omer_texts[jcalendar.day_of_omer()]}\n\n' \
                f'{texsts.after_text}</code>'

    return full_text
Exemple #2
0
def convert_greg_to_heb(date_: str) -> str:
    try:
        pydate = date.fromisoformat(date_)
    except ValueError:
        raise IncorrectGregorianDateException

    calendar = JewishCalendar.from_date(pydate)
    jewish_date = f'{calendar.jewish_day} {JEWISH_MONTHS_GENETIVE[calendar.jewish_month_name()]} {calendar.jewish_year},' \
                  f' {WEEKDAYS[calendar.gregorian_date.weekday()]}'
    return jewish_date
def convert_greg_to_heb(date_: str) -> Tuple[str, InlineKeyboardMarkup]:
    try:
        pydate = date.fromisoformat(date_)
    except ValueError:
        raise IncorrectGregorianDateException

    calendar = JewishCalendar.from_date(pydate)
    jewish_date = f'{calendar.jewish_day} {JEWISH_MONTHS_GENITIVE[calendar.jewish_month_name()]} {calendar.jewish_year},' \
                  f' {WEEKDAYS[calendar.gregorian_date.weekday()]}'
    kb = get_zmanim_by_date_buttons([pydate])
    return jewish_date, kb
Exemple #4
0
def get_omer_time(user_data: UserData) -> Optional[str]:
    tz_name = TimezoneFinder().timezone_at(lat=user_data.latitude,
                                           lng=user_data.longitude)
    location = GeoLocation('',
                           user_data.latitude,
                           user_data.longitude,
                           time_zone=tz_name)
    calendar = ZmanimCalendar(60, geo_location=location, date=date.today())
    jcalendar = JewishCalendar.from_date(date.today())

    omer_day = jcalendar.day_of_omer()
    if not omer_day:
        return

    if jcalendar.is_assur_bemelacha(
    ) and jcalendar.is_tomorrow_assur_bemelacha():
        return
    elif jcalendar.is_tomorrow_assur_bemelacha():
        omer_time = calendar.candle_lighting()
    else:
        omer_time = calendar.tzais()

    if isinstance(omer_time, dt):
        return omer_time.isoformat()