Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- `jewish_calendar.is_taanis_bechorim()` function added
- `jewish_calendar.is_shabbos_mevorchim()` function added
- `jewish_calendar.significant_shabbos()` function added

## [0.3.1] - 2020-11-05
### Added
Expand Down
196 changes: 196 additions & 0 deletions test/test_jewish_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,202 @@ def test_day_of_omer_outside_of_omer(self):
calendar = JewishCalendar(test.test_helper.standard_monday_chaseirim(), 7, 1)
self.assertIsNone(calendar.day_of_omer())

def test_significant_shabbos_for_standard_monday_chaseirim(self):
year = test.test_helper.standard_monday_chaseirim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-6'],
'parshas_shekalim': ['11-29'],
'parshas_zachor': ['12-13'],
'parshas_parah': ['12-20'],
'parshas_hachodesh': ['12-27'],
'shabbos_hagadol': ['1-12']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_standard_monday_shelaimim(self):
year = test.test_helper.standard_monday_shelaimim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-6'],
'parshas_shekalim': ['11-27'],
'parshas_zachor': ['12-11'],
'parshas_parah': ['12-18'],
'parshas_hachodesh': ['12-25'],
'shabbos_hagadol': ['1-10']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_standard_tuesday_kesidran(self):
year = test.test_helper.standard_tuesday_kesidran()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-5'],
'parshas_shekalim': ['11-27'],
'parshas_zachor': ['12-11'],
'parshas_parah': ['12-18'],
'parshas_hachodesh': ['12-25'],
'shabbos_hagadol': ['1-10']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_standard_thursday_kesidran(self):
year = test.test_helper.standard_thursday_kesidran()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-3'],
'parshas_shekalim': ['11-25'],
'parshas_zachor': ['12-9'],
'parshas_parah': ['12-23'],
'parshas_hachodesh': ['1-1'],
'shabbos_hagadol': ['1-8']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_standard_thursday_shelaimim(self):
year = test.test_helper.standard_thursday_shelaimim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-3'],
'parshas_shekalim': ['12-1'],
'parshas_zachor': ['12-8'],
'parshas_parah': ['12-22'],
'parshas_hachodesh': ['12-29'],
'shabbos_hagadol': ['1-14']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_standard_shabbos_chaseirim(self):
year = test.test_helper.standard_shabbos_chaseirim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-8'],
'parshas_shekalim': ['12-1'],
'parshas_zachor': ['12-8'],
'parshas_parah': ['12-22'],
'parshas_hachodesh': ['12-29'],
'shabbos_hagadol': ['1-14']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_standard_shabbos_shelaimim(self):
year = test.test_helper.standard_shabbos_shelaimim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-8'],
'parshas_shekalim': ['11-29'],
'parshas_zachor': ['12-13'],
'parshas_parah': ['12-20'],
'parshas_hachodesh': ['12-27'],
'shabbos_hagadol': ['1-12']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_monday_chaseirim(self):
year = test.test_helper.leap_monday_chaseirim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-6'],
'parshas_shekalim': ['12-27'],
'parshas_zachor': ['13-11'],
'parshas_parah': ['13-18'],
'parshas_hachodesh': ['13-25'],
'shabbos_hagadol': ['1-10']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_monday_shelaimim(self):
year = test.test_helper.leap_monday_shelaimim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-6'],
'parshas_shekalim': ['12-25'],
'parshas_zachor': ['13-9'],
'parshas_parah': ['13-23'],
'parshas_hachodesh': ['1-1'],
'shabbos_hagadol': ['1-8']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_tuesday_kesidran(self):
year = test.test_helper.leap_tuesday_kesidran()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-5'],
'parshas_shekalim': ['12-25'],
'parshas_zachor': ['13-9'],
'parshas_parah': ['13-23'],
'parshas_hachodesh': ['1-1'],
'shabbos_hagadol': ['1-8']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_thursday_chaseirim(self):
year = test.test_helper.leap_thursday_chaseirim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-3'],
'parshas_shekalim': ['13-1'],
'parshas_zachor': ['13-8'],
'parshas_parah': ['13-22'],
'parshas_hachodesh': ['13-29'],
'shabbos_hagadol': ['1-14']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_thursday_shelaimim(self):
year = test.test_helper.leap_thursday_shelaimim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-3'],
'parshas_shekalim': ['12-29'],
'parshas_zachor': ['13-13'],
'parshas_parah': ['13-20'],
'parshas_hachodesh': ['13-27'],
'shabbos_hagadol': ['1-12']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_shabbos_chaseirim(self):
year = test.test_helper.leap_shabbos_chaseirim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-8'],
'parshas_shekalim': ['12-29'],
'parshas_zachor': ['13-13'],
'parshas_parah': ['13-20'],
'parshas_hachodesh': ['13-27'],
'shabbos_hagadol': ['1-12']
}
self.assertEqual(result, expected)

def test_significant_shabbos_for_leap_shabbos_shelaimim(self):
year = test.test_helper.leap_shabbos_shelaimim()

result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
expected = {
'shabbos_shuva': ['7-8'],
'parshas_shekalim': ['12-27'],
'parshas_zachor': ['13-11'],
'parshas_parah': ['13-18'],
'parshas_hachodesh': ['13-25'],
'shabbos_hagadol': ['1-10']
}
self.assertEqual(result, expected)

def test_molad_as_datetime(self):
expected_offset = (2, 20, 56, 496000) # UTC is 2:20:56.496 behind Jerusalem Local Time
calendar = JewishCalendar(5776, 8, 1)
Expand Down
22 changes: 22 additions & 0 deletions zmanim/hebrew_calendar/jewish_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ def __repr__(self):
def significant_day(self) -> Optional[str]:
return getattr(self, f'_{self.jewish_month_name()}_significant_day', None)()

def significant_shabbos(self) -> Optional[str]:
if self.day_of_week != 7:
return None
if self.jewish_month == 1:
if self.jewish_day == 1:
return 'parshas_hachodesh'
elif self.jewish_day in range(8, 15):
return 'shabbos_hagadol'
elif self.jewish_month == 7 and self.jewish_day in range(3, 10):
return 'shabbos_shuva'
elif self.jewish_month == (self.months_in_jewish_year() - 1) and self.jewish_day in range(25, 31):
return 'parshas_shekalim'
elif self.jewish_month == self.months_in_jewish_year():
if self.jewish_day == 1:
return 'parshas_shekalim'
elif self.jewish_day in range(7, 14):
return 'parshas_zachor'
elif self.jewish_day in range(17, 24):
return 'parshas_parah'
elif self.jewish_day in range(24, 30):
return 'parshas_hachodesh'

def is_assur_bemelacha(self) -> bool:
return self.day_of_week == 7 or self.is_yom_tov_assur_bemelacha()

Expand Down