Skip to content

Commit cdbd16d

Browse files
committed
Add significant shabbos implantation with tests
1 parent 5faf6e1 commit cdbd16d

2 files changed

Lines changed: 218 additions & 0 deletions

File tree

test/test_jewish_calendar.py

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,202 @@ def test_day_of_omer_outside_of_omer(self):
668668
calendar = JewishCalendar(test.test_helper.standard_monday_chaseirim(), 7, 1)
669669
self.assertIsNone(calendar.day_of_omer())
670670

671+
def test_significant_shabbes_for_standard_monday_chaseirim(self):
672+
year = test.test_helper.standard_monday_chaseirim()
673+
674+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
675+
expected = {
676+
'shabbos_shuva': ['7-6'],
677+
'parshas_shekalim': ['11-29'],
678+
'parshas_zachor': ['12-13'],
679+
'parshas_parah': ['12-20'],
680+
'parshas_hachodesh': ['12-27'],
681+
'shabbos_hagadol': ['1-12']
682+
}
683+
self.assertEqual(result, expected)
684+
685+
def test_significant_shabbes_for_standard_monday_shelaimim(self):
686+
year = test.test_helper.standard_monday_shelaimim()
687+
688+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
689+
expected = {
690+
'shabbos_shuva': ['7-6'],
691+
'parshas_shekalim': ['11-27'],
692+
'parshas_zachor': ['12-11'],
693+
'parshas_parah': ['12-18'],
694+
'parshas_hachodesh': ['12-25'],
695+
'shabbos_hagadol': ['1-10']
696+
}
697+
self.assertEqual(result, expected)
698+
699+
def test_significant_shabbes_for_standard_tuesday_kesidran(self):
700+
year = test.test_helper.standard_tuesday_kesidran()
701+
702+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
703+
expected = {
704+
'shabbos_shuva': ['7-5'],
705+
'parshas_shekalim': ['11-27'],
706+
'parshas_zachor': ['12-11'],
707+
'parshas_parah': ['12-18'],
708+
'parshas_hachodesh': ['12-25'],
709+
'shabbos_hagadol': ['1-10']
710+
}
711+
self.assertEqual(result, expected)
712+
713+
def test_significant_shabbes_for_standard_thursday_kesidran(self):
714+
year = test.test_helper.standard_thursday_kesidran()
715+
716+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
717+
expected = {
718+
'shabbos_shuva': ['7-3'],
719+
'parshas_shekalim': ['11-25'],
720+
'parshas_zachor': ['12-9'],
721+
'parshas_parah': ['12-23'],
722+
'parshas_hachodesh': ['1-1'],
723+
'shabbos_hagadol': ['1-8']
724+
}
725+
self.assertEqual(result, expected)
726+
727+
def test_significant_shabbes_for_standard_thursday_shelaimim(self):
728+
year = test.test_helper.standard_thursday_shelaimim()
729+
730+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
731+
expected = {
732+
'shabbos_shuva': ['7-3'],
733+
'parshas_shekalim': ['12-1'],
734+
'parshas_zachor': ['12-8'],
735+
'parshas_parah': ['12-22'],
736+
'parshas_hachodesh': ['12-29'],
737+
'shabbos_hagadol': ['1-14']
738+
}
739+
self.assertEqual(result, expected)
740+
741+
def test_significant_shabbes_for_standard_shabbos_chaseirim(self):
742+
year = test.test_helper.standard_shabbos_chaseirim()
743+
744+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
745+
expected = {
746+
'shabbos_shuva': ['7-8'],
747+
'parshas_shekalim': ['12-1'],
748+
'parshas_zachor': ['12-8'],
749+
'parshas_parah': ['12-22'],
750+
'parshas_hachodesh': ['12-29'],
751+
'shabbos_hagadol': ['1-14']
752+
}
753+
self.assertEqual(result, expected)
754+
755+
def test_significant_shabbes_for_standard_shabbos_shelaimim(self):
756+
year = test.test_helper.standard_shabbos_shelaimim()
757+
758+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
759+
expected = {
760+
'shabbos_shuva': ['7-8'],
761+
'parshas_shekalim': ['11-29'],
762+
'parshas_zachor': ['12-13'],
763+
'parshas_parah': ['12-20'],
764+
'parshas_hachodesh': ['12-27'],
765+
'shabbos_hagadol': ['1-12']
766+
}
767+
self.assertEqual(result, expected)
768+
769+
def test_significant_shabbes_for_leap_monday_chaseirim(self):
770+
year = test.test_helper.leap_monday_chaseirim()
771+
772+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
773+
expected = {
774+
'shabbos_shuva': ['7-6'],
775+
'parshas_shekalim': ['12-27'],
776+
'parshas_zachor': ['13-11'],
777+
'parshas_parah': ['13-18'],
778+
'parshas_hachodesh': ['13-25'],
779+
'shabbos_hagadol': ['1-10']
780+
}
781+
self.assertEqual(result, expected)
782+
783+
def test_significant_shabbes_for_leap_monday_shelaimim(self):
784+
year = test.test_helper.leap_monday_shelaimim()
785+
786+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
787+
expected = {
788+
'shabbos_shuva': ['7-6'],
789+
'parshas_shekalim': ['12-25'],
790+
'parshas_zachor': ['13-9'],
791+
'parshas_parah': ['13-23'],
792+
'parshas_hachodesh': ['1-1'],
793+
'shabbos_hagadol': ['1-8']
794+
}
795+
self.assertEqual(result, expected)
796+
797+
def test_significant_shabbes_for_leap_tuesday_kesidran(self):
798+
year = test.test_helper.leap_tuesday_kesidran()
799+
800+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
801+
expected = {
802+
'shabbos_shuva': ['7-5'],
803+
'parshas_shekalim': ['12-25'],
804+
'parshas_zachor': ['13-9'],
805+
'parshas_parah': ['13-23'],
806+
'parshas_hachodesh': ['1-1'],
807+
'shabbos_hagadol': ['1-8']
808+
}
809+
self.assertEqual(result, expected)
810+
811+
def test_significant_shabbes_for_leap_thursday_chaseirim(self):
812+
year = test.test_helper.leap_thursday_chaseirim()
813+
814+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
815+
expected = {
816+
'shabbos_shuva': ['7-3'],
817+
'parshas_shekalim': ['13-1'],
818+
'parshas_zachor': ['13-8'],
819+
'parshas_parah': ['13-22'],
820+
'parshas_hachodesh': ['13-29'],
821+
'shabbos_hagadol': ['1-14']
822+
}
823+
self.assertEqual(result, expected)
824+
825+
def test_significant_shabbes_for_leap_thursday_shelaimim(self):
826+
year = test.test_helper.leap_thursday_shelaimim()
827+
828+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
829+
expected = {
830+
'shabbos_shuva': ['7-3'],
831+
'parshas_shekalim': ['12-29'],
832+
'parshas_zachor': ['13-13'],
833+
'parshas_parah': ['13-20'],
834+
'parshas_hachodesh': ['13-27'],
835+
'shabbos_hagadol': ['1-12']
836+
}
837+
self.assertEqual(result, expected)
838+
839+
def test_significant_shabbes_for_leap_shabbos_chaseirim(self):
840+
year = test.test_helper.leap_shabbos_chaseirim()
841+
842+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
843+
expected = {
844+
'shabbos_shuva': ['7-8'],
845+
'parshas_shekalim': ['12-29'],
846+
'parshas_zachor': ['13-13'],
847+
'parshas_parah': ['13-20'],
848+
'parshas_hachodesh': ['13-27'],
849+
'shabbos_hagadol': ['1-12']
850+
}
851+
self.assertEqual(result, expected)
852+
853+
def test_significant_shabbes_for_leap_shabbos_shelaimim(self):
854+
year = test.test_helper.leap_shabbos_shelaimim()
855+
856+
result = test.test_helper.all_days_matching(year, lambda c: c.significant_shabbos())
857+
expected = {
858+
'shabbos_shuva': ['7-8'],
859+
'parshas_shekalim': ['12-27'],
860+
'parshas_zachor': ['13-11'],
861+
'parshas_parah': ['13-18'],
862+
'parshas_hachodesh': ['13-25'],
863+
'shabbos_hagadol': ['1-10']
864+
}
865+
self.assertEqual(result, expected)
866+
671867
def test_molad_as_datetime(self):
672868
expected_offset = (2, 20, 56, 496000) # UTC is 2:20:56.496 behind Jerusalem Local Time
673869
calendar = JewishCalendar(5776, 8, 1)

zmanim/hebrew_calendar/jewish_calendar.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ def __repr__(self):
3737
def significant_day(self) -> Optional[str]:
3838
return getattr(self, f'_{self.jewish_month_name()}_significant_day', None)()
3939

40+
def significant_shabbos(self) -> Optional[str]:
41+
if self.day_of_week != 7:
42+
return None
43+
if self.jewish_month == 1:
44+
if self.jewish_day == 1:
45+
return 'parshas_hachodesh'
46+
elif self.jewish_day in range(8, 15):
47+
return 'shabbos_hagadol'
48+
elif self.jewish_month == 7 and self.jewish_day in range(3, 10):
49+
return 'shabbos_shuva'
50+
elif self.jewish_month == (self.months_in_jewish_year() - 1) and self.jewish_day in range(25, 31):
51+
return 'parshas_shekalim'
52+
elif self.jewish_month == self.months_in_jewish_year():
53+
if self.jewish_day == 1:
54+
return 'parshas_shekalim'
55+
elif self.jewish_day in range(7, 14):
56+
return 'parshas_zachor'
57+
elif self.jewish_day in range(17, 24):
58+
return 'parshas_parah'
59+
elif self.jewish_day in range(24, 30):
60+
return 'parshas_hachodesh'
61+
4062
def is_assur_bemelacha(self) -> bool:
4163
return self.day_of_week == 7 or self.is_yom_tov_assur_bemelacha()
4264

0 commit comments

Comments
 (0)