Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use instance's type to construct return instance
  • Loading branch information
yankyhoffman committed Mar 5, 2023
commit c5edaeef62e8e5c74fc37e9bd224c8220b243201
6 changes: 3 additions & 3 deletions zmanim/hebrew_calendar/jewish_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ def __add__(self, addend) -> 'JewishDate':
if isinstance(addend, int):
return copy.copy(self).forward(addend)
elif isinstance(addend, timedelta):
return JewishDate(self.gregorian_date + addend)
return type(self)(self.gregorian_date + addend)
raise ValueError

def __sub__(self, subtrahend):
if isinstance(subtrahend, int):
return copy.copy(self).back(subtrahend)
elif isinstance(subtrahend, timedelta):
return JewishDate(self.gregorian_date - subtrahend)
return type(self)(self.gregorian_date - subtrahend)
elif isinstance(subtrahend, JewishDate):
return self.gregorian_date - subtrahend.gregorian_date
elif isinstance(subtrahend, date):
Expand Down Expand Up @@ -535,4 +535,4 @@ def _chalakim_since_molad_tohu(year: int, month: int) -> int:
@staticmethod
def _month_number_from_tishrei(year: int, month: int) -> int:
leap = JewishDate._is_jewish_leap_year(year)
return 1 + ((month + (6 if leap else 5)) % (13 if leap else 12))
return 1 + ((month + (6 if leap else 5)) % (13 if leap else 12))