Skip to content

Commit

Permalink
Merge pull request #101 from holiday-jp/holiday-accompanying-coronati…
Browse files Browse the repository at this point in the history
…on-day

Holiday accompanying coronation day
  • Loading branch information
k1LoW authored Dec 23, 2018
2 parents 30bbb32 + eb7271a commit 7feef73
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 110 deletions.
4 changes: 4 additions & 0 deletions holidays.yml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@
2019-02-11: 建国記念の日
2019-03-21: 春分の日
2019-04-29: 昭和の日
2019-04-30: 休日
2019-05-01: 休日(祝日扱い)
2019-05-02: 休日
2019-05-03: 憲法記念日
2019-05-04: みどりの日
2019-05-05: こどもの日
Expand All @@ -770,6 +773,7 @@
2019-09-16: 敬老の日
2019-09-23: 秋分の日
2019-10-14: 体育の日
2019-10-22: 休日(祝日扱い)
2019-11-03: 文化の日
2019-11-04: 文化の日 振替休日
2019-11-23: 勤労感謝の日
Expand Down
24 changes: 24 additions & 0 deletions holidays_detailed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4559,6 +4559,24 @@
week_en: Monday
name: 昭和の日
name_en: Showa Day
2019-04-30:
date: 2019-04-30
week:
week_en: Tuesday
name: 休日
name_en: Holiday
2019-05-01:
date: 2019-05-01
week:
week_en: Wednesday
name: 休日(祝日扱い)
name_en: Holiday
2019-05-02:
date: 2019-05-02
week:
week_en: Thursday
name: 休日
name_en: Holiday
2019-05-03:
date: 2019-05-03
week:
Expand Down Expand Up @@ -4619,6 +4637,12 @@
week_en: Monday
name: 体育の日
name_en: Health and Sports Day
2019-10-22:
date: 2019-10-22
week:
week_en: Tuesday
name: 休日(祝日扱い)
name_en: Holiday
2019-11-03:
date: 2019-11-03
week:
Expand Down
89 changes: 87 additions & 2 deletions spec/holidays_detailed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

it 'Google calendar result should have date of holidays_detailed.yml' do
@span.each do |date|
next if date[0] == Date.new(2019, 10, 22)
expect(@google_calendar.holiday?(date[0])).to eq true
end
end

it 'holidays_detailed.yml shoud have date of Google calendar' do
@gholidays.each do |date, name|
expect(@holidays_detailed.key?(date)).to eq true
expect(@holidays_detailed[date]['name']).to eq name
expect(@holidays_detailed[date]['name']).to eq(name).or eq('休日').or eq('休日(祝日扱い)')
end
end

Expand All @@ -39,8 +40,92 @@
expect(@holidays_detailed.key?(Date::parse('2041-08-12'))).to eq true
expect(@holidays_detailed.key?(Date::parse('2047-08-12'))).to eq true
end
end

context 'Emperor\'s Birthday' do
before do
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
end

it 'holidays_detail.yml should have holiday in Showa Emperor\'s Birthday' do
1970.upto(1988) do |year|
expect(@holidays_detailed.key?(Date.new(year, 4, 29))).to eq true
end
end

it 'holidays_detail.yml should have holiday in Heisei Emperor\'s Birthday' do
1989.upto(2018) do |year|
expect(@holidays_detailed.key?(Date.new(year, 12, 23))).to eq true
end
end

it 'holidays_detail.yml should have no holiday in 2019 Emperor\'s Birthday' do
expect(@holidays_detailed.key?(Date.new(2019, 2, 23))).to eq false
expect(@holidays_detailed.key?(Date.new(2019, 12, 23))).to eq false
end

it 'holidays_detail.yml should have holiday in New Emperor\'s Birthday' do
2020.upto(2050) do |year|
expect(@holidays_detailed.key?(Date.new(year, 2, 23))).to eq true
end
end
end

context 'Holiday in lieu' do
before do
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
end

it 'If holiday is Sunday, Holiday in lieu should exist. (>= 1973.4.30)' do
@holidays_detailed.each do |date, detail|
if date >= Date.new(1973, 4, 30) && date.wday == 0 && !detail['name'].match(/振替休日/)
expect(@holidays_detailed.key?(date + 1)).to eq true
end
end
end
end

context 'Tokyo Olympic' do
before do
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
end

it 'If tokyo olympic year, 海の日 should be moved' do
expect(@holidays_detailed.key?(Date::parse('2020-07-20'))).to eq false
expect(@holidays_detailed.key?(Date::parse('2020-07-23'))).to eq true
end

it 'If tokyo olympic year, 山の日 should be moved' do
expect(@holidays_detailed.key?(Date::parse('2020-08-11'))).to eq false
expect(@holidays_detailed.key?(Date::parse('2020-08-10'))).to eq true
end

it 'If tokyo olympic year, 体育の日 should be moved' do
expect(@holidays_detailed.key?(Date::parse('2020-10-12'))).to eq false
expect(@holidays_detailed.key?(Date::parse('2020-07-24'))).to eq true
end
end

context 'Coronation Day / 天皇の即位の日及び即位礼正殿の儀の行われる日を休日とする法律' do
before do
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
end
it '天皇の即位の日の平成31年(2019年)5月1日及び即位礼正殿の儀が行われる日の平成31年(2019年)10月22日は、休日となります' do
expect(@holidays_detailed.key?(Date::parse('2019-05-01'))).to eq true
expect(@holidays_detailed.key?(Date::parse('2019-10-22'))).to eq true
end
it 'また、これらの休日は国民の祝日扱いとなるため、平成31年(2019年)4月30日と5月2日も休日となります' do
expect(@holidays_detailed.key?(Date::parse('2019-04-30'))).to eq true
expect(@holidays_detailed.key?(Date::parse('2019-05-02'))).to eq true
end
end

context 'holiday.yml' do
before do
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
end

it 'holidays_detailed.yml should have date of holiday.yml' do
it 'holidays_detailed.yml should have date of holiday.yml and holiday.yml should have of holiday_detail.yml' do
holidays = YAML.load_file(File.expand_path('../../holidays.yml', __FILE__))
holidays.each do |date, name|
expect(@holidays_detailed.key?(date)).to eq true
Expand Down
106 changes: 0 additions & 106 deletions spec/holidays_spec.rb

This file was deleted.

4 changes: 2 additions & 2 deletions spec/syukujitsu_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
context 'Check holidays.yml by syukujitsu.csv' do
before do
@holidays = YAML.load_file(File.expand_path('../../holidays.yml', __FILE__))
csv_url = 'http://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv'
csv_url = 'https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv'
csv = open(csv_url).read
@cholidays = CSV.parse(csv, headers: true, encoding: 'Shift_JIS')
end
Expand All @@ -17,7 +17,7 @@
@cholidays.each do |row|
d = Date::parse(row[0])
expect(@holidays.key?(d)).to eq true
expect(@holidays[d]).to eq row[1].encode('UTF-8', 'Shift_JIS')
expect(@holidays[d]).to eq(row[1].encode('UTF-8', 'Shift_JIS')).or match(/振替休日/)
end
end

Expand Down

0 comments on commit 7feef73

Please sign in to comment.