Skip to content

Commit 7c2563f

Browse files
committed
Add significant shabbos implantation with tests
1 parent 62e5147 commit 7c2563f

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
@@ -677,6 +677,202 @@ def test_day_of_omer_outside_of_omer(self):
677677
calendar = JewishCalendar(test.test_helper.standard_monday_chaseirim(), 7, 1)
678678
self.assertIsNone(calendar.day_of_omer())
679679

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