From 0e4b1ec9c974ee4a28ee74ab86a01defd18aa7c8 Mon Sep 17 00:00:00 2001 From: JanakiRamChittineni <341781521+raams95@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:00:02 -0600 Subject: [PATCH] Do not close TARGET on Good Friday, Easter Monday, 1 May or 26 December before 2000 TARGET only closed on New Year's Day and Christmas Day in 1999 (plus 31 December 1999). Good Friday, Easter Monday, 1 May and 26 December became closing days from 2000. --- financepy/utils/calendar.py | 6 +++--- tests/unit/test_calendar.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/financepy/utils/calendar.py b/financepy/utils/calendar.py index 3f8012df..655144ed 100644 --- a/financepy/utils/calendar.py +++ b/financepy/utils/calendar.py @@ -3085,7 +3085,7 @@ def holiday_target(self, dt: Date, day_in_year): if m == 1 and d == 1: # new year's day return True - if m == 5 and d == 1: # May day + if m == 5 and d == 1 and y >= 2000: # May day return True if not MIN_CALENDAR_YEAR <= y <= MAX_CALENDAR_YEAR: @@ -3094,14 +3094,14 @@ def holiday_target(self, dt: Date, day_in_year): if m == 12 and d == 25: # Xmas bank holiday return True - if m == 12 and d == 26: # Xmas bank holiday + if m == 12 and d == 26 and y >= 2000: # Xmas bank holiday return True # Additional closing days for the Year 2000 and euro cash changeovers if m == 12 and d == 31 and y in (1999, 2001): return True - if m == 3 or m == 4: + if y >= 2000 and (m == 3 or m == 4): # Easter Monday falls between Mar 24 and Apr 26 and Good Friday # is three days before it return day_in_year - easter_monday_day[y - MIN_CALENDAR_YEAR] in (0, -3) diff --git a/tests/unit/test_calendar.py b/tests/unit/test_calendar.py index b042919c..26584caf 100644 --- a/tests/unit/test_calendar.py +++ b/tests/unit/test_calendar.py @@ -405,6 +405,30 @@ def test_target_additional_closing_days(): assert cal.is_business_day(Date(31, 12, 2026)) +def test_target_closing_days_start_in_2000(): + cal = Calendar(CalendarTypes.TARGET) + + # Good Friday and Easter Monday became TARGET closing days in 2000 + for dt in [Date(2, 4, 1999), Date(5, 4, 1999)]: + assert not cal.is_holiday(dt), dt + assert cal.is_business_day(dt), dt + + for dt in [Date(21, 4, 2000), Date(24, 4, 2000), Date(18, 4, 2025), Date(21, 4, 2025)]: + assert cal.is_holiday(dt), dt + assert not cal.is_business_day(dt), dt + + # 1999 closing days were New Year's Day, Christmas Day and 31 December + for dt in [Date(1, 1, 1999), Date(25, 12, 1999), Date(31, 12, 1999)]: + assert cal.is_holiday(dt), dt + + # 1 May and 26 December are closing days from 2000 + for dt in [Date(1, 5, 2000), Date(26, 12, 2000), Date(1, 5, 2026), Date(26, 12, 2025)]: + assert cal.is_holiday(dt), dt + + for dt in [Date(1, 5, 1999), Date(26, 12, 1999)]: + assert not cal.is_holiday(dt), dt + + def test_modified_following_does_not_cross_month(): cal = Calendar(CalendarTypes.WEEKEND)