Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Juneteenth for UT #290

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion lib/validation/custom_method_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Definitions
module Validation
class CustomMethod
VALID_ARGUMENTS = ["date", "year", "month", "day"]
VALID_ARGUMENTS = ["date", "year", "month", "day", "region"]

def call(methods)
methods.each do |name, method|
Expand Down
35 changes: 33 additions & 2 deletions us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ months:
- name: Juneteenth National Independence Day
regions: [us]
mday: 19
observed: to_weekday_if_weekend(date)
observed: juneteenth_national_independence_day(region, date)
year_ranges:
from: 2021
- name: Emancipation Day in Texas # fixed
Expand Down Expand Up @@ -360,6 +360,31 @@ 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_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: region, date
ruby: |
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 @@ -706,7 +731,13 @@ tests:
date: ['2017-6-19']
regions: ["us_tx"]
expect:
name: "Emancipation Day in Texas"
name: "Emancipation Day in Texas"
- given:
date: ['2024-06-17', '2027-06-21', '2028-06-19', '2033-06-20']
regions: ["us_ut"]
options: ["observed"]
expect:
name: "Juneteenth National Independence Day"

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