Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions financepy/utils/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading