Repository: peopledoc/workalendar
Pull request #460 (2020-02-05 16:16:08)

Fixing the Israel holidays
refs #461

<!-- if your contribution is a fix -->

- [x] Tests with a significant number of years to be tested for your calendar.
- [x] Changelog amended with a mention describing your changes. **Note** *Please do NOT change the version number here. It's the project maintainers' duty.*

<!-- Release management

- Commit for the tag:
    - [ ] Edit version in setup.py
    - [ ] Add version in Changelog.md ; trim things
    - [ ] Push & wait for the tests to be green
    - [ ] tag me.
    - [ ] build sdist + wheel packages (``make package``)
- Back to dev commit:
    - [ ] Edit version in setup.py
    - [ ] Add the "master / nothing to see here" in Changelog.md
    - [ ] Push & wait for the tests to be green
- [ ] Merge --ff
- Github stuff
    - [ ] Push tag in Github
    - [ ] Edit release on Github using the changelog.
    - [ ] Delete branch
- [ ] upload release on PyPI using ``twine``
- [ ] (*optional*) Make feeback on the various PR or issues.

 -->



Patch:
diff --git a/Changelog.md b/Changelog.md
index 61b8894..5762e77 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,7 +2,7 @@
 
 ## master (unreleased)
 
-Nothing here yet.
+- Added Israel holidays eves and removed holidays which are not affecting the working days in Israel (#461).
 
 ## v8.0.2 (2020-01-24)
 
diff --git a/workalendar/asia/israel.py b/workalendar/asia/israel.py
index 12be00f..c6c5eb0 100644
--- a/workalendar/asia/israel.py
+++ b/workalendar/asia/israel.py
@@ -30,52 +30,47 @@ class Israel(Calendar):
             day = hebrew_date.day
 
             if month == 7:
-                if day in {1, 2, 3}:
+                if day == 1:
+                    days.append((current_date - delta, "Rosh Hashana Eve"))
                     days.append((current_date, "Rosh Hashana"))
+                    days.append((current_date + delta, "Rosh Hashana"))
                 elif day == 10:
+                    days.append((current_date - delta, "Yom Kippur Eve"))
                     days.append((current_date, "Yom Kippur"))
-                elif day in range(15, 22):
+                elif day == 15:
+                    days.append((current_date - delta, "Sukkot Eve"))
                     days.append((current_date, "Sukkot"))
                 elif day == 22:
+                    days.append((current_date - delta, "Shmini Atzeres Eve"))
                     days.append((current_date, "Shmini Atzeres"))
-            elif month == 12 and not HebrewDate._is_leap(jewish_year):
-                if day == 14:
-                    days.append((current_date, "Purim"))
+            elif month == 1:
                 if day == 15:
-                    days.append((current_date, "Shushan Purim"))
-            elif month == 13:
-                if day == 14:
-                    days.append((current_date, "Purim"))
-                elif day == 15:
-                    days.append((current_date, "Shushan Purim"))
-            elif month == 1 and day in {15, 21}:
-                days.append((current_date, "Pesach"))
+                    days.append((current_date - delta, "Pesach Eve"))
+                    days.append((current_date, "Pesach"))
+                elif day == 21:
+                    days.append((current_date - delta, "7th of Pesach Eve"))
+                    days.append((current_date, "7th of Pesach"))
             elif month == 2:
                 if day == 5:
+                    independence_date = current_date
                     if hebrew_date.weekday() == 6:
-                        days.append(
-                            (
-                                HebrewDate(jewish_year, month, 4).to_pydate(),
-                                "Independence Day",
-                            )
-                        )
+                        independence_date = HebrewDate(
+                            jewish_year, month, 4
+                        ).to_pydate()
                     elif hebrew_date.weekday() == 7:
-                        days.append(
-                            (
-                                HebrewDate(jewish_year, month, 3).to_pydate(),
-                                "Independence Day",
-                            )
-                        )
+                        independence_date = HebrewDate(
+                            jewish_year, month, 3
+                        ).to_pydate()
                     elif hebrew_date.weekday() == 2:
-                        days.append(
-                            (
-                                HebrewDate(jewish_year, month, 6).to_pydate(),
-                                "Independence Day",
-                            )
-                        )
-                    else:
-                        days.append((current_date, "Independence Day"))
+                        independence_date = HebrewDate(
+                            jewish_year, month, 6
+                        ).to_pydate()
+                    days.append(
+                        (independence_date - delta, "Independence Day Eve")
+                    )
+                    days.append((independence_date, "Independence Day"))
             elif month == 3 and day == 6:
+                days.append((current_date - delta, "Shavout Eve"))
                 days.append((current_date, "Shavout"))
 
             current_date += delta


Test patch:
diff --git a/workalendar/tests/test_asia.py b/workalendar/tests/test_asia.py
index 7868299..6b0753c 100644
--- a/workalendar/tests/test_asia.py
+++ b/workalendar/tests/test_asia.py
@@ -540,18 +540,37 @@ class IsraelTest(GenericCalendarTest):
         )  # Independence Day (Yom Ha-Atzmaut), was delayed in 2019
         self.assertIn(date(2019, 6, 9), holidays)  # Shavuot
         self.assertIn(
-            date(2019, 9, 30), holidays
+            date(2019, 9, 29), holidays
         )  # Jewish New Year (Rosh Ha-Shana)
         self.assertIn(
-            date(2019, 10, 1), holidays
+            date(2019, 9, 30), holidays
         )  # Jewish New Year (Rosh Ha-Shana)
         self.assertIn(
-            date(2019, 10, 2), holidays
+            date(2019, 10, 1), holidays
         )  # Jewish New Year (Rosh Ha-Shana)
         self.assertIn(date(2019, 10, 9), holidays)  # Yom Kippur
         self.assertIn(date(2019, 10, 14), holidays)  # Sukkot
         self.assertIn(date(2019, 10, 20), holidays)  # Sukkot
 
-        # Leap year Purim
-        self.assertIn(date(2019, 3, 21), holidays)  # purim
-        self.assertIn(date(2019, 3, 22), holidays)  # shushan purim
+    def test_holidays_2020(self):
+        calculated_holidays = self.cal.holidays_set(2020)
+        known_holidays = {
+            date(2020, 9, 18),  # Rosh Hashana Eve
+            date(2020, 9, 19),  # Rosh Hashana A
+            date(2020, 9, 20),  # Rosh Hashana B
+            date(2020, 9, 27),  # Kippur Eve
+            date(2020, 9, 28),  # Kippur
+            date(2020, 10, 2),  # Sukot A Eve
+            date(2020, 10, 3),  # Sukot A
+            date(2020, 10, 9),  # Sukot B Eve
+            date(2020, 10, 10),  # Sukot B
+            date(2020, 4, 8),  # Pesach A Eve
+            date(2020, 4, 9),  # Pesach A
+            date(2020, 4, 14),  # Pesach B Eve
+            date(2020, 4, 15),  # Pesach B
+            date(2020, 4, 28),  # Independence Day Eve
+            date(2020, 4, 29),  # Independence Day
+            date(2020, 5, 28),  # Shavuot Eve
+            date(2020, 5, 29),  # Shavuot
+        }
+        self.assertEqual(calculated_holidays, known_holidays)