Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Update Indepdence day to be only observed on Monday if falls into Sunday
Browse files Browse the repository at this point in the history
  • Loading branch information
Phan Le committed Jun 23, 2015
1 parent 5116c71 commit 4719650
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/us.yaml
Expand Up @@ -35,7 +35,7 @@ months:
- name: Independence Day
regions: [us]
mday: 4
observed: to_weekday_if_weekend
observed: to_monday_if_sunday
9:
- name: Labor Day
week: 1
Expand Down
2 changes: 1 addition & 1 deletion lib/holidays/north_america.rb
Expand Up @@ -53,7 +53,7 @@ def self.holidays_by_month
7 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Canada Day", :regions => [:ca]},
{:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
{:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]},
{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
{:mday => 4, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Independence Day", :regions => [:us]}],
8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
{:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
{:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
Expand Down
2 changes: 1 addition & 1 deletion lib/holidays/us.rb
Expand Up @@ -27,7 +27,7 @@ def self.holidays_by_month
{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
7 => [{:mday => 4, :observed => lambda { |date| puts 'here'; Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Independence Day", :regions => [:us]}],
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}],
Expand Down
10 changes: 10 additions & 0 deletions test/test_holidays.rb
Expand Up @@ -75,6 +75,16 @@ def test_region_params
holidays = Holidays.on(@date, [:ca_bc,:ca])
assert_equal 1, holidays.length
end

def test_independence_day
assert_equal 1, Holidays.on(Date.civil(2014,7,4), :us, :observed).length

# Not bank holiday if falls into a Sat
assert_equal 0, Holidays.on(Date.civil(2015,7,3), :us, :observed).length

# Bank holiday if falls into a Sun
assert_equal 1, Holidays.on(Date.civil(2021,7,5), :us, :observed).length
end

def test_observed_dates
# Should fall on Tuesday the 1st
Expand Down

0 comments on commit 4719650

Please sign in to comment.