Skip to content

Commit 7feef73

Browse files
authored
Merge pull request #101 from holiday-jp/holiday-accompanying-coronation-day
Holiday accompanying coronation day
2 parents 30bbb32 + eb7271a commit 7feef73

5 files changed

Lines changed: 117 additions & 110 deletions

File tree

holidays.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@
760760
2019-02-11: 建国記念の日
761761
2019-03-21: 春分の日
762762
2019-04-29: 昭和の日
763+
2019-04-30: 休日
764+
2019-05-01: 休日(祝日扱い)
765+
2019-05-02: 休日
763766
2019-05-03: 憲法記念日
764767
2019-05-04: みどりの日
765768
2019-05-05: こどもの日
@@ -770,6 +773,7 @@
770773
2019-09-16: 敬老の日
771774
2019-09-23: 秋分の日
772775
2019-10-14: 体育の日
776+
2019-10-22: 休日(祝日扱い)
773777
2019-11-03: 文化の日
774778
2019-11-04: 文化の日 振替休日
775779
2019-11-23: 勤労感謝の日

holidays_detailed.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4559,6 +4559,24 @@
45594559
week_en: Monday
45604560
name: 昭和の日
45614561
name_en: Showa Day
4562+
2019-04-30:
4563+
date: 2019-04-30
4564+
week:
4565+
week_en: Tuesday
4566+
name: 休日
4567+
name_en: Holiday
4568+
2019-05-01:
4569+
date: 2019-05-01
4570+
week:
4571+
week_en: Wednesday
4572+
name: 休日(祝日扱い)
4573+
name_en: Holiday
4574+
2019-05-02:
4575+
date: 2019-05-02
4576+
week:
4577+
week_en: Thursday
4578+
name: 休日
4579+
name_en: Holiday
45624580
2019-05-03:
45634581
date: 2019-05-03
45644582
week:
@@ -4619,6 +4637,12 @@
46194637
week_en: Monday
46204638
name: 体育の日
46214639
name_en: Health and Sports Day
4640+
2019-10-22:
4641+
date: 2019-10-22
4642+
week:
4643+
week_en: Tuesday
4644+
name: 休日(祝日扱い)
4645+
name_en: Holiday
46224646
2019-11-03:
46234647
date: 2019-11-03
46244648
week:

spec/holidays_detailed_spec.rb

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121

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

2829
it 'holidays_detailed.yml shoud have date of Google calendar' do
2930
@gholidays.each do |date, name|
3031
expect(@holidays_detailed.key?(date)).to eq true
31-
expect(@holidays_detailed[date]['name']).to eq name
32+
expect(@holidays_detailed[date]['name']).to eq(name).or eq('休日').or eq('休日(祝日扱い)')
3233
end
3334
end
3435

@@ -39,8 +40,92 @@
3940
expect(@holidays_detailed.key?(Date::parse('2041-08-12'))).to eq true
4041
expect(@holidays_detailed.key?(Date::parse('2047-08-12'))).to eq true
4142
end
43+
end
44+
45+
context 'Emperor\'s Birthday' do
46+
before do
47+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
48+
end
49+
50+
it 'holidays_detail.yml should have holiday in Showa Emperor\'s Birthday' do
51+
1970.upto(1988) do |year|
52+
expect(@holidays_detailed.key?(Date.new(year, 4, 29))).to eq true
53+
end
54+
end
55+
56+
it 'holidays_detail.yml should have holiday in Heisei Emperor\'s Birthday' do
57+
1989.upto(2018) do |year|
58+
expect(@holidays_detailed.key?(Date.new(year, 12, 23))).to eq true
59+
end
60+
end
61+
62+
it 'holidays_detail.yml should have no holiday in 2019 Emperor\'s Birthday' do
63+
expect(@holidays_detailed.key?(Date.new(2019, 2, 23))).to eq false
64+
expect(@holidays_detailed.key?(Date.new(2019, 12, 23))).to eq false
65+
end
66+
67+
it 'holidays_detail.yml should have holiday in New Emperor\'s Birthday' do
68+
2020.upto(2050) do |year|
69+
expect(@holidays_detailed.key?(Date.new(year, 2, 23))).to eq true
70+
end
71+
end
72+
end
73+
74+
context 'Holiday in lieu' do
75+
before do
76+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
77+
end
78+
79+
it 'If holiday is Sunday, Holiday in lieu should exist. (>= 1973.4.30)' do
80+
@holidays_detailed.each do |date, detail|
81+
if date >= Date.new(1973, 4, 30) && date.wday == 0 && !detail['name'].match(/振替休日/)
82+
expect(@holidays_detailed.key?(date + 1)).to eq true
83+
end
84+
end
85+
end
86+
end
87+
88+
context 'Tokyo Olympic' do
89+
before do
90+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
91+
end
92+
93+
it 'If tokyo olympic year, 海の日 should be moved' do
94+
expect(@holidays_detailed.key?(Date::parse('2020-07-20'))).to eq false
95+
expect(@holidays_detailed.key?(Date::parse('2020-07-23'))).to eq true
96+
end
97+
98+
it 'If tokyo olympic year, 山の日 should be moved' do
99+
expect(@holidays_detailed.key?(Date::parse('2020-08-11'))).to eq false
100+
expect(@holidays_detailed.key?(Date::parse('2020-08-10'))).to eq true
101+
end
102+
103+
it 'If tokyo olympic year, 体育の日 should be moved' do
104+
expect(@holidays_detailed.key?(Date::parse('2020-10-12'))).to eq false
105+
expect(@holidays_detailed.key?(Date::parse('2020-07-24'))).to eq true
106+
end
107+
end
108+
109+
context 'Coronation Day / 天皇の即位の日及び即位礼正殿の儀の行われる日を休日とする法律' do
110+
before do
111+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
112+
end
113+
it '天皇の即位の日の平成31年(2019年)5月1日及び即位礼正殿の儀が行われる日の平成31年(2019年)10月22日は、休日となります' do
114+
expect(@holidays_detailed.key?(Date::parse('2019-05-01'))).to eq true
115+
expect(@holidays_detailed.key?(Date::parse('2019-10-22'))).to eq true
116+
end
117+
it 'また、これらの休日は国民の祝日扱いとなるため、平成31年(2019年)4月30日と5月2日も休日となります' do
118+
expect(@holidays_detailed.key?(Date::parse('2019-04-30'))).to eq true
119+
expect(@holidays_detailed.key?(Date::parse('2019-05-02'))).to eq true
120+
end
121+
end
122+
123+
context 'holiday.yml' do
124+
before do
125+
@holidays_detailed = YAML.load_file(File.expand_path('../../holidays_detailed.yml', __FILE__))
126+
end
42127

43-
it 'holidays_detailed.yml should have date of holiday.yml' do
128+
it 'holidays_detailed.yml should have date of holiday.yml and holiday.yml should have of holiday_detail.yml' do
44129
holidays = YAML.load_file(File.expand_path('../../holidays.yml', __FILE__))
45130
holidays.each do |date, name|
46131
expect(@holidays_detailed.key?(date)).to eq true

spec/holidays_spec.rb

Lines changed: 0 additions & 106 deletions
This file was deleted.

spec/syukujitsu_csv_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
context 'Check holidays.yml by syukujitsu.csv' do
99
before do
1010
@holidays = YAML.load_file(File.expand_path('../../holidays.yml', __FILE__))
11-
csv_url = 'http://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv'
11+
csv_url = 'https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv'
1212
csv = open(csv_url).read
1313
@cholidays = CSV.parse(csv, headers: true, encoding: 'Shift_JIS')
1414
end
@@ -17,7 +17,7 @@
1717
@cholidays.each do |row|
1818
d = Date::parse(row[0])
1919
expect(@holidays.key?(d)).to eq true
20-
expect(@holidays[d]).to eq row[1].encode('UTF-8', 'Shift_JIS')
20+
expect(@holidays[d]).to eq(row[1].encode('UTF-8', 'Shift_JIS')).or match(/振替休日/)
2121
end
2222
end
2323

0 commit comments

Comments
 (0)