Skip to content

Commit

Permalink
Changed name of param 'include_day' to 'prefix_day'.
Browse files Browse the repository at this point in the history
  • Loading branch information
simlist committed Feb 28, 2023
1 parent bb5fc5b commit 7d0adc8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.

`2.2.0`_(2023-02-??)
====================
* Added `include_day` param to ``festival`` and ``holiday`` methods and
* Added `prefix_day` param to ``festival`` and ``holiday`` methods and
functions.

`2.1.0`_ (2023-02-12)
Expand Down
34 changes: 17 additions & 17 deletions src/pyluach/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ def _day_of_holiday(self, israel, hebrew=False):
-------
str
"""
name = (
utils._fast_day_string(self)
or utils._festival_string(self, israel)
)
name = utils._festival_string(self, israel)
if name is not None:
first_day = utils._first_day_of_holiday(utils.Days(name))
holiday = utils.Days(name)
# if holiday is utils.Days.SHAVUOS and israel:
# return ''
first_day = utils._first_day_of_holiday(holiday)
if first_day:
day = HebrewDate(self.year, *first_day) - self + 1
if hebrew:
Expand Down Expand Up @@ -236,7 +236,7 @@ def festival(
israel=False,
hebrew=False,
include_working_days=True,
include_day=False
prefix_day=False
):
"""Return name of Jewish festival of date.
Expand All @@ -255,19 +255,19 @@ def festival(
``True`` to include festival days on which melacha (work) is
allowed; ie. Pesach Sheni, Chol Hamoed, etc.
Default is ``True``.
include_day : bool, optional
prefix_day : bool, optional
``True`` to prefix multi day festivals with the day of the
festival. Default is ``False``.
Examples
--------
>>> pesach = HebrewDate(2023, 1, 15)
>>> pesach.festival(include_day=True)
>>> pesach.festival(prefix_day=True)
'1 Pesach'
>>> pesach.festival(hebrew=True, include_day=True)
>>> pesach.festival(hebrew=True, prefix_day=True)
'א׳ פסח'
>>> shavuos = HebrewDate(5783, 3, 6)
>>> shavuos.festival(israel=True, include_day=True)
>>> shavuos.festival(israel=True, prefix_day=True)
'Shavuos'
Returns
Expand All @@ -279,13 +279,13 @@ def festival(
name = utils._festival_string(
self, israel, hebrew, include_working_days
)
if include_day and name is not None:
if prefix_day and name is not None:
day = self._day_of_holiday(israel=israel, hebrew=hebrew)
if day:
return f'{day} {name}'
return name

def holiday(self, israel=False, hebrew=False, include_day=False):
def holiday(self, israel=False, hebrew=False, prefix_day=False):
"""Return name of Jewish holiday of the date.
The holidays include the major and minor religious Jewish
Expand All @@ -299,19 +299,19 @@ def holiday(self, israel=False, hebrew=False, include_day=False):
hebrew : bool, optional
``True`` if you want the holiday name in Hebrew letters. Default is
``False``, which returns the name transliterated into English.
include_day : bool, optional
prefix_day : bool, optional
``True`` to prefix multi day holidays with the day of the
holiday. Default is ``False``.
Examples
--------
>>> pesach = HebrewDate(2023, 1, 15)
>>> pesach.holiday(include_day=True)
>>> pesach.holiday(prefix_day=True)
'1 Pesach'
>>> pesach.holiday(hebrew=True, include_day=True)
>>> pesach.holiday(hebrew=True, prefix_day=True)
'א׳ פסח'
>>> taanis_esther = HebrewDate(5783, 12, 13)
>>> taanis_esther.holiday(include_day=True)
>>> taanis_esther.holiday(prefix_day=True)
'Taanis Esther'
Returns
Expand All @@ -322,7 +322,7 @@ def holiday(self, israel=False, hebrew=False, include_day=False):
"""
return (
self.fast_day(hebrew=hebrew)
or self.festival(israel, hebrew, include_day=include_day)
or self.festival(israel, hebrew, prefix_day=prefix_day)
)


Expand Down
24 changes: 12 additions & 12 deletions src/pyluach/hebrewcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ def festival(
israel=False,
hebrew=False,
include_working_days=True,
include_day=False
prefix_day=False
):
"""Return Jewish festival of given day.
Expand All @@ -1271,20 +1271,20 @@ def festival(
``True`` to include festival days on which melacha (work) is
allowed; ie. Pesach Sheni, Chol Hamoed, etc.
Default is ``True``.
include_day : bool, optional
prefix_day : bool, optional
``True`` to prefix multi day festivals with the day of the
festival. Default is ``False``.
Examples
--------
>>> from pyluach.dates import HebrewDate
pesach = HebrewDate(2023, 1, 15)
>>> festival(pesach, include_day=True)
>>> festival(pesach, prefix_day=True)
'1 Pesach'
>>> festival(pesach, hebrew=True, include_day=True)
>>> festival(pesach, hebrew=True, prefix_day=True)
'א׳ פסח'
>>> shavuos = HebrewDate(5783, 3, 6)
>>> festival(shavuos, israel=True, include_day=True)
>>> festival(shavuos, israel=True, prefix_day=True)
'Shavuos'
Returns
Expand All @@ -1293,10 +1293,10 @@ def festival(
The name of the festival or ``None`` if the given date is not
a Jewish festival.
"""
return date.festival(israel, hebrew, include_working_days, include_day)
return date.festival(israel, hebrew, include_working_days, prefix_day)


def holiday(date, israel=False, hebrew=False, include_day=False):
def holiday(date, israel=False, hebrew=False, prefix_day=False):
"""Return Jewish holiday of given date.
The holidays include the major and minor religious Jewish
Expand All @@ -1312,20 +1312,20 @@ def holiday(date, israel=False, hebrew=False, include_day=False):
hebrew : bool, optional
``True`` if you want the holiday name in Hebrew letters. Default
is ``False``, which returns the name transliterated into English.
include_day : bool, optional
prefix_day : bool, optional
``True`` to prefix multi day holidays with the day of the
holiday. Default is ``False``.
Examples
--------
>>> from pyluach.dates import HebrewDate
>>> pesach = HebrewDate(2023, 1, 15)
>>> holiday(pesach, include_day=True)
>>> holiday(pesach, prefix_day=True)
'1 Pesach'
>>> holiday(pesach, hebrew=True, include_day=True)
>>> holiday(pesach, hebrew=True, prefix_day=True)
'א׳ פסח'
>>> taanis_esther = HebrewDate(5783, 12, 13)
>>> holiday(taanis_esther, include_day=True)
>>> holiday(taanis_esther, prefix_day=True)
'Taanis Esther'
Returns
Expand All @@ -1334,4 +1334,4 @@ def holiday(date, israel=False, hebrew=False, include_day=False):
The name of the holiday or ``None`` if the given date is not
a Jewish holiday.
"""
return date.holiday(israel, hebrew, include_day)
return date.holiday(israel, hebrew, prefix_day)
3 changes: 3 additions & 0 deletions tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ def test_festival(self):

def test_day_of_holiday(self):
assert HebrewDate(5783, 12, 14)._day_of_holiday(israel=False) == ''
# shavuos = HebrewDate(5783, 3, 6)
# assert shavuos.holiday(prefix_day=True) == '1 Shavuos'
# assert shavuos.holiday(israel=True, prefix_day=True) == 'Shavuos'


def test_to_pydate():
Expand Down
20 changes: 10 additions & 10 deletions tests/test_hebrewcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,23 +321,23 @@ def test_roshhashana(self):
for included_days in [True, False]
))
assert (
holiday(roshhashana, hebrew=True, include_day=True)
holiday(roshhashana, hebrew=True, prefix_day=True)
== 'א׳ ראש השנה'
)
assert festival(roshhashana + 1, include_day=True) == '2 Rosh Hashana'
assert festival(roshhashana + 1, prefix_day=True) == '2 Rosh Hashana'

def test_yomkippur(self):
yom_kippur = dates.HebrewDate(5775, 7, 10)
assert holiday(yom_kippur) == 'Yom Kippur'
assert holiday(yom_kippur, hebrew=True) == 'יום כיפור'
assert festival(yom_kippur, include_working_days=False) == 'Yom Kippur'
assert holiday(yom_kippur, include_day=True) == 'Yom Kippur'
assert holiday(yom_kippur, prefix_day=True) == 'Yom Kippur'

def test_succos(self):
second_day = dates.HebrewDate(5782, 7, 16)
day = dates.HebrewDate(5778, 7, 18)
assert festival(day) == 'Succos'
assert holiday(day, hebrew=True, include_day=True) == 'ד׳ סוכות'
assert holiday(day, hebrew=True, prefix_day=True) == 'ד׳ סוכות'
day2 = dates.HebrewDate(5778, 7, 23)
assert festival(day2, israel=True, hebrew=True) is None
assert festival(day, include_working_days=False) is None
Expand All @@ -354,14 +354,14 @@ def test_shmini(self):
shmini = dates.HebrewDate(5780, 7, 22)
assert holiday(shmini, True) == 'Shmini Atzeres'
assert holiday(shmini) == 'Shmini Atzeres'
assert holiday(shmini + 1, include_day=True) == 'Simchas Torah'
assert holiday(shmini + 1, israel=True, include_day=True) is None
assert holiday(shmini + 1, prefix_day=True) == 'Simchas Torah'
assert holiday(shmini + 1, israel=True, prefix_day=True) is None

def test_chanuka(self):
for year in [5778, 5787]:
chanuka = dates.HebrewDate(year, 9, 25)
assert (
festival(chanuka + 7, hebrew=True, include_day=True)
festival(chanuka + 7, hebrew=True, prefix_day=True)
== 'ח׳ חנוכה'
)
for i in range(8):
Expand Down Expand Up @@ -405,9 +405,9 @@ def test_pesach(self):
festival(pesach + 1, israel=True, include_working_days=False)
is None
)
assert holiday(pesach, include_day=True) == '1 Pesach'
assert holiday(pesach, prefix_day=True) == '1 Pesach'
assert (
festival(pesach + 2, include_working_days=False, include_day=True)
festival(pesach + 2, include_working_days=False, prefix_day=True)
is None
)

Expand Down Expand Up @@ -436,7 +436,7 @@ def test_shavuos(self):
not_shavuos = dates.HebrewDate(5782, 4, 7)
assert festival(not_shavuos) is None
assert (
festival(shavuos + 1, hebrew=True, include_day=True) == 'ב׳ שבועות'
festival(shavuos + 1, hebrew=True, prefix_day=True) == 'ב׳ שבועות'
)

def test_tubeav(self):
Expand Down

0 comments on commit 7d0adc8

Please sign in to comment.