Repository: peopledoc/workalendar (python)
Issue: Issue with USA Thanksgiving Friday (Blackfriday) calculation
USA core.py has an issue where Thanksgiving Friday is computed as 4th Friday of November (drawing a parallel from US Thanksgiving which falls on 4th Thursday of November).
While the logic works most of the time, it fails if 1st Nov happens to be a Friday.
Ideally, Thanksgiving Friday should be calculated as a day after Thanksgiving, which is also the definition.
version - master (7.2.0.dev0)
_Though I believe it is platform independent._
I have tried it on Mac OS 10.13 with Python 3.6.5
Pull request description: Fix USA: correct implementation for Thanksgiving Friday
This pull-request superseeds and thus, closes #423. Also, it fixes #422


- [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.*


Patch:
diff --git a/Changelog.md b/Changelog.md
index e917b36..2a3596a 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,7 +2,8 @@
 
 ## master (unreleased)
 
-- Added Geneva calendar by @cw-intellineers (#420) 
+- Added Geneva calendar by @cw-intellineers (#420)
+- Bugfix for USA: Fixed incorrect implementation for Thanksgiving Friday, thx @deveshvar (#422).
 
 ## v7.1.0 (2019-11-15)
 
diff --git a/workalendar/usa/core.py b/workalendar/usa/core.py
index bdcbf50..900b679 100644
--- a/workalendar/usa/core.py
+++ b/workalendar/usa/core.py
@@ -144,11 +144,12 @@ class UnitedStates(WesternCalendar, ChristianMixin):
         return (self.get_election_date(year), self.election_day_label)
 
     def get_thanksgiving_friday(self, year):
-        "Thanksgiving friday is on the 4th Friday in November"
-        return (
-            self.get_nth_weekday_in_month(year, 11, FRI, 4),
-            self.thanksgiving_friday_label
-        )
+        """
+        Thanksgiving friday is on the day following Thanksgiving Day
+        """
+        thanksgiving = UnitedStates.get_nth_weekday_in_month(year, 11, THU, 4)
+        thanksgiving_friday = thanksgiving + timedelta(days=1)
+        return (thanksgiving_friday, self.thanksgiving_friday_label)
 
     def get_confederate_day(self, year):
         """


Test patch:
diff --git a/workalendar/tests/test_usa.py b/workalendar/tests/test_usa.py
index 407a8ea..ab005b1 100644
--- a/workalendar/tests/test_usa.py
+++ b/workalendar/tests/test_usa.py
@@ -189,6 +189,14 @@ class UnitedStatesTest(GenericCalendarTest):
             holidays = self.cal.holidays_set(year)
             self.assertNotIn(self.cal.get_election_date(year), holidays)
 
+    def test_thanksgiving_friday(self):
+        day, _ = self.cal.get_thanksgiving_friday(2017)
+        self.assertEqual(day, date(2017, 11, 24))
+        day, _ = self.cal.get_thanksgiving_friday(2018)
+        self.assertEqual(day, date(2018, 11, 23))
+        day, _ = self.cal.get_thanksgiving_friday(2019)
+        self.assertEqual(day, date(2019, 11, 29))
+
     def test_thanksgiving_friday_label(self):
         _, label = self.cal.get_thanksgiving_friday(2017)
         self.assertEqual(label, "Thanksgiving Friday")
@@ -448,6 +456,11 @@ class CaliforniaTest(NoColumbus, UnitedStatesTest):
         self.assertIn(date(2015, 3, 31), holidays)  # Cesar Chavez Day
         self.assertIn(date(2015, 11, 27), holidays)  # Thanksgiving Friday
 
+    def test_state_year_2019(self):
+        holidays = self.cal.holidays_set(2019)
+        self.assertIn(date(2019, 3, 31), holidays)  # Cesar Chavez Day
+        self.assertIn(date(2019, 11, 29), holidays)  # Thanksgiving Friday
+
 
 class CaliforniaEducationTest(CaliforniaTest):
     cal_class = CaliforniaEducation