Skip to content

Commit

Permalink
fix UK 2022 Spring Bank Holiday
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenoris committed Jul 1, 2022
1 parent fbcd679 commit f3b5566
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/calendars/uk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ function isholiday(::UKSettlement, dt::Dates.Date)
||
# May Day, Early May Bank Holiday
(adjustweekendholidayPost(findweekday(Dates.Monday, yy, 5, 1, true)) == dt && yy != 1995 && yy != 2020)
||
# Spring Bank Holiday
(adjustweekendholidayPost(findweekday(Dates.Monday, yy, 5, 1, false)) == dt && yy != 2012 && yy != 2002)
)
return true
end

# Spring Bank Holiday
if yy == 2022 && dt == Dates.Date(2022, 6, 2)
return true
elseif adjustweekendholidayPost(findweekday(Dates.Monday, yy, 5, 1, false)) == dt && yy != 2012 && yy != 2002 && yy != 2022
return true
end

# Easter occurs up to April, which is before August (mm < 8). See test/easter-min-max.jl .
# Holidays based on easter date
dt_rata::Int = Dates.days(dt)
Expand Down
14 changes: 13 additions & 1 deletion test/calendar_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,20 @@ test_bdays(:WeekendsOnly, (2019, 8, 23), (2019, 8, 24), 1)
@test isbday(hc_uk, Dates.Date(2020, 5, 4)) == true # Early May Bank Holiday was moved to May 8th in 2020
@test isbday(hc_uk, Dates.Date(2020, 5, 8)) == false # Early May Bank Holiday was moved to May 8th in 2020

# 2022 UK holidays
# 2021 UK Holidays
@test isbday(hc_uk, Dates.Date(2021, 5, 3)) == false # May Day
@test isbday(hc_uk, Dates.Date(2021, 5, 4)) == true
@test isbday(hc_uk, Dates.Date(2021, 5, 31)) == false # spring bank holiday
@test isbday(hc_uk, Dates.Date(2021, 6, 1)) == true # spring bank holiday

# 2022 UK holidays slightly move due to Platinum Jubilee (#57)
@test isbday(hc_uk, Dates.Date(2022, 6, 3)) == false # Platinum Jubilee of Queen Elizabeth II.
@test isbday(hc_uk, Dates.Date(2022, 5, 2)) == false # May Day
@test isbday(hc_uk, Dates.Date(2022, 5, 30)) == true
@test isbday(hc_uk, Dates.Date(2022, 6, 2)) == false # Spring Bank Holiday
@test isbday(hc_uk, Dates.Date(2022, 8, 29)) == false # Summer Bank Holiday
@test isbday(hc_uk, Dates.Date(2022, 12, 26)) == false # Boxing
@test isbday(hc_uk, Dates.Date(2022, 12, 27)) == false # Christmas

@test tobday(hc_brazil, Dates.Date(2013, 02, 08)) == Dates.Date(2013, 02, 08) # regular friday
@test tobday(hc_brazil, Dates.Date(2013, 02, 09)) == Dates.Date(2013, 02, 13) # after carnaval
Expand Down

0 comments on commit f3b5566

Please sign in to comment.