Skip to content

Commit

Permalink
calculate observed juneteenth in UT
Browse files Browse the repository at this point in the history
  • Loading branch information
erluti committed Sep 12, 2024
1 parent 1d1d0ea commit 83c190a
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,9 @@ months:
- name: Juneteenth National Independence Day
regions: [us]
mday: 19
observed: to_weekday_if_weekend(date)
observed: juneteenth_national_independence_day(date, region)
year_ranges:
from: 2021
- name: Juneteenth National Freedom Day
regions: [us_ut]
function: juneteenth_national_freedom_day(year)
year_ranges:
from: 2022
- name: Emancipation Day in Texas # fixed
regions: [us_tx]
mday: 19
Expand Down Expand Up @@ -365,22 +360,32 @@ methods:
beginning_of_month = Date.civil(year, month, 1)
king_day = Date.civil(year, month, day_of_holiday)
king_day.downto(beginning_of_month).find {|date| date if date.wday == 5 }
juneteenth_national_freedom_day:
# If Saturday or Sunday, it's on next Monday
# If it's Tuesday through Friday, it's on the preceeding Monday
arguments: year
juneteenth_national_independence_day:
# In Utah...
# When Saturday or Sunday, it's on next Monday
# When Tuesday through Friday, it's on the preceeding Monday
# all other states it's observed like "to_weekday_if_weekend"
arguments: date, region
ruby: |
date = Date.civil(year, 6, 19)
case date.wday
when 1
date
when 2,3,4,5
date - (date.wday - 1)
when 6
date + 2
when 0
if region == 'us_ut'
case date.wday
when 1
date
when 2,3,4,5
date - (date.wday - 1)
when 6
date + 2
when 0
date + 1
end
elsif date.wday == 0
date + 1
elsif date.wday == 6
date - 1
else
date
end
election_day:
# Tuesday after the first Monday of November
arguments: year
Expand Down Expand Up @@ -731,8 +736,9 @@ tests:
- given:
date: ['2024-06-17', '2027-06-21', '2028-06-19', '2033-06-20']
regions: ["us_ut"]
options: ["observed"]
expect:
name: "Juneteenth National Freedom Day"
name: "Juneteenth National Independence Day"

- given:
date: ['2017-6-20', '2020-6-19', '2021-6-21']
Expand Down

0 comments on commit 83c190a

Please sign in to comment.