Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_hebrew_calendar(cls, gregorian_year):
"""
Build and cache the Hebrew calendar for the given Gregorian Year.
"""
if gregorian_year not in cls.hebrew_calendars:
# Build the hebrew calendar for year
days = []
current_date = date(gregorian_year, 1, 1)
while current_date.year == gregorian_year:
hebrew_date = GregorianDate(
year=current_date.year,
month=current_date.month,
day=current_date.day,
).to_heb()
days.append(
(hebrew_date, current_date)
)
current_date += timedelta(days=1)
# Store it in the class property
cls.hebrew_calendars[gregorian_year] = days
# Return the hebrew calendar
return cls.hebrew_calendars[gregorian_year]
def get_variable_days(self, year):
days = super().get_variable_days(year)
hebrew_date = GregorianDate(year=year, month=1, day=1).to_heb()
jewish_year = hebrew_date.year
holidays_hebrew_dates = [
(HebrewDate(jewish_year, 6, 29), "Rosh Hashana Eve"),
(HebrewDate(jewish_year + 1, 7, 1), "Rosh Hashana"),
(HebrewDate(jewish_year + 1, 7, 2), "Rosh Hashana"),
(HebrewDate(jewish_year + 1, 7, 9), "Yom Kippur Eve"),
(HebrewDate(jewish_year + 1, 7, 10), "Yom Kippur"),
(HebrewDate(jewish_year + 1, 7, 14), "Sukkot Eve"),
(HebrewDate(jewish_year + 1, 7, 15), "Sukkot"),
(HebrewDate(jewish_year + 1, 7, 21), "Shmini Atzeres Eve"),
(HebrewDate(jewish_year + 1, 7, 22), "Shmini Atzeres"),
(HebrewDate(jewish_year, 1, 14), "Pesach Eve"),
(HebrewDate(jewish_year, 1, 15), "Pesach"),
(HebrewDate(jewish_year, 1, 20), "7th of Pesach Eve"),
(HebrewDate(jewish_year, 1, 21), "7th of Pesach"),