holiday_japan 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 726269abbeb3b1416db1333ef33a1ed85bd93221b6654a280b360926a773f671
4
- data.tar.gz: 37514c34b1a602d0ea499eba8dc468486b396d6056c9bba1b556bdbde7408be6
3
+ metadata.gz: ff5b05052915590e2ce0e47e5850dbb591763607afd0654edc992b209a689248
4
+ data.tar.gz: 0b37dc4a6c7238ec21ba7c9d6b8786abece7b124f4fe05adb8c7994cc6e9dcb0
5
5
  SHA512:
6
- metadata.gz: 1270c6086d552e8ea9fd86245611b2f40f3fbb76307ef2647f443b3d3682fb922b5bcc3b6b74e9dc6bcbc2f6e9ae6b2d593871d968fbb8b8625833258b8c3bbc
7
- data.tar.gz: 512ada76ed1555d96061a0c8323b47690283f4411193256735fcac96b35b6fc680b84a245f3de7602807c909b185bdab7e53f575521c97edc268b2b2daeefbd4
6
+ metadata.gz: 0b60f539c53afb041807e92b3ad624ca2c9fc06f2c758b95adda7072df60f8cefb3c158c8ba86fad0c520c620b5409b654ccc1cbb81ca0d7d232ddb6328cfb02
7
+ data.tar.gz: 45a4d2ea31afbcae07875799f712e595e0535b3d56889cd43c79c39973ed9a2bffad0daeafdb726dee0d647de712fed0f7abb8d25dc753a69eadf6ed1cd1631b
data/README.md CHANGED
@@ -35,140 +35,150 @@
35
35
  * `check(date)` ― Dateクラスのオブジェクトによる祝日判定
36
36
 
37
37
  ```ruby
38
- HolidayJapan.check(Date.new(2018,3,21))
38
+ HolidayJapan.check(Date.new(2019,3,21))
39
39
  => true
40
40
  ```
41
41
 
42
42
  * `name(date)` ― 日付が祝日の場合は祝日名を返し、祝日でなければ nil を返す。
43
43
 
44
44
  ```ruby
45
- HolidayJapan.name(Date.new(2018,3,21))
45
+ HolidayJapan.name(Date.new(2019,3,21))
46
46
  => "春分の日"
47
47
  ```
48
48
 
49
49
  * `print_year(year)` ― ある年の祝日一覧をプリント
50
50
 
51
51
  ```
52
- $ ruby -r holiday_japan -e 'HolidayJapan.print_year 2018'
53
- listing year 2018...
54
- 2018-01-01 Mon 元日
55
- 2018-01-08 Mon 成人の日
56
- 2018-02-11 Sun 建国記念の日
57
- 2018-02-12 Mon 振替休日
58
- 2018-03-21 Wed 春分の日
59
- 2018-04-29 Sun 昭和の日
60
- 2018-04-30 Mon 振替休日
61
- 2018-05-03 Thu 憲法記念日
62
- 2018-05-04 Fri みどりの日
63
- 2018-05-05 Sat こどもの日
64
- 2018-07-16 Mon 海の日
65
- 2018-08-11 Sat 山の日
66
- 2018-09-17 Mon 敬老の日
67
- 2018-09-23 Sun 秋分の日
68
- 2018-09-24 Mon 振替休日
69
- 2018-10-08 Mon 体育の日
70
- 2018-11-03 Sat 文化の日
71
- 2018-11-23 Fri 勤労感謝の日
72
- 2018-12-23 Sun 天皇誕生日
73
- 2018-12-24 Mon 振替休日
52
+ $ ruby -r holiday_japan -e 'HolidayJapan.print_year 2019'
53
+ listing year 2019...
54
+ 2019-01-01 Tue 元日
55
+ 2019-01-14 Mon 成人の日
56
+ 2019-02-11 Mon 建国記念の日
57
+ 2019-03-21 Thu 春分の日
58
+ 2019-04-29 Mon 昭和の日
59
+ 2019-04-30 Tue 国民の休日
60
+ 2019-05-01 Wed 即位の日(名称未定)
61
+ 2019-05-02 Thu 国民の休日
62
+ 2019-05-03 Fri 憲法記念日
63
+ 2019-05-04 Sat みどりの日
64
+ 2019-05-05 Sun こどもの日
65
+ 2019-05-06 Mon 振替休日
66
+ 2019-07-15 Mon 海の日
67
+ 2019-08-11 Sun 山の日
68
+ 2019-08-12 Mon 振替休日
69
+ 2019-09-16 Mon 敬老の日
70
+ 2019-09-23 Mon 秋分の日
71
+ 2019-10-14 Mon 体育の日
72
+ 2019-10-22 Tue 即位礼正殿の儀
73
+ 2019-11-03 Sun 文化の日
74
+ 2019-11-04 Mon 振替休日
75
+ 2019-11-23 Sat 勤労感謝の日
74
76
  ```
75
77
 
76
78
  * `list_year(year)` ― ある年について、 [日付, 祝日名] のArrayを返す
77
79
 
78
80
  ```ruby
79
- HolidayJapan.list_year(2018)
80
- => [[#<Date: 2018-01-01 ((2458120j,0s,0n),+0s,2299161j)>, "元日"],
81
- [#<Date: 2018-01-08 ((2458127j,0s,0n),+0s,2299161j)>, "成人の日"],
82
- [#<Date: 2018-02-11 ((2458161j,0s,0n),+0s,2299161j)>, "建国記念の日"],
83
- [#<Date: 2018-02-12 ((2458162j,0s,0n),+0s,2299161j)>, "振替休日"],
84
- [#<Date: 2018-03-21 ((2458199j,0s,0n),+0s,2299161j)>, "春分の日"],
85
- [#<Date: 2018-04-29 ((2458238j,0s,0n),+0s,2299161j)>, "昭和の日"],
86
- [#<Date: 2018-04-30 ((2458239j,0s,0n),+0s,2299161j)>, "振替休日"],
87
- [#<Date: 2018-05-03 ((2458242j,0s,0n),+0s,2299161j)>, "憲法記念日"],
88
- [#<Date: 2018-05-04 ((2458243j,0s,0n),+0s,2299161j)>, "みどりの日"],
89
- [#<Date: 2018-05-05 ((2458244j,0s,0n),+0s,2299161j)>, "こどもの日"],
90
- [#<Date: 2018-07-16 ((2458316j,0s,0n),+0s,2299161j)>, "海の日"],
91
- [#<Date: 2018-08-11 ((2458342j,0s,0n),+0s,2299161j)>, "山の日"],
92
- [#<Date: 2018-09-17 ((2458379j,0s,0n),+0s,2299161j)>, "敬老の日"],
93
- [#<Date: 2018-09-23 ((2458385j,0s,0n),+0s,2299161j)>, "秋分の日"],
94
- [#<Date: 2018-09-24 ((2458386j,0s,0n),+0s,2299161j)>, "振替休日"],
95
- [#<Date: 2018-10-08 ((2458400j,0s,0n),+0s,2299161j)>, "体育の日"],
96
- [#<Date: 2018-11-03 ((2458426j,0s,0n),+0s,2299161j)>, "文化の日"],
97
- [#<Date: 2018-11-23 ((2458446j,0s,0n),+0s,2299161j)>, "勤労感謝の日"],
98
- [#<Date: 2018-12-23 ((2458476j,0s,0n),+0s,2299161j)>, "天皇誕生日"],
99
- [#<Date: 2018-12-24 ((2458477j,0s,0n),+0s,2299161j)>, "振替休日"]]
81
+ HolidayJapan.list_year(2019)
82
+ => [[#<Date: 2019-01-01 ((2458485j,0s,0n),+0s,2299161j)>, "元日"],
83
+ [#<Date: 2019-01-14 ((2458498j,0s,0n),+0s,2299161j)>, "成人の日"],
84
+ [#<Date: 2019-02-11 ((2458526j,0s,0n),+0s,2299161j)>, "建国記念の日"],
85
+ [#<Date: 2019-03-21 ((2458564j,0s,0n),+0s,2299161j)>, "春分の日"],
86
+ [#<Date: 2019-04-29 ((2458603j,0s,0n),+0s,2299161j)>, "昭和の日"],
87
+ [#<Date: 2019-04-30 ((2458604j,0s,0n),+0s,2299161j)>, "国民の休日"],
88
+ [#<Date: 2019-05-01 ((2458605j,0s,0n),+0s,2299161j)>, "即位の日(名称未定)"],
89
+ [#<Date: 2019-05-02 ((2458606j,0s,0n),+0s,2299161j)>, "国民の休日"],
90
+ [#<Date: 2019-05-03 ((2458607j,0s,0n),+0s,2299161j)>, "憲法記念日"],
91
+ [#<Date: 2019-05-04 ((2458608j,0s,0n),+0s,2299161j)>, "みどりの日"],
92
+ [#<Date: 2019-05-05 ((2458609j,0s,0n),+0s,2299161j)>, "こどもの日"],
93
+ [#<Date: 2019-05-06 ((2458610j,0s,0n),+0s,2299161j)>, "振替休日"],
94
+ [#<Date: 2019-07-15 ((2458680j,0s,0n),+0s,2299161j)>, "海の日"],
95
+ [#<Date: 2019-08-11 ((2458707j,0s,0n),+0s,2299161j)>, "山の日"],
96
+ [#<Date: 2019-08-12 ((2458708j,0s,0n),+0s,2299161j)>, "振替休日"],
97
+ [#<Date: 2019-09-16 ((2458743j,0s,0n),+0s,2299161j)>, "敬老の日"],
98
+ [#<Date: 2019-09-23 ((2458750j,0s,0n),+0s,2299161j)>, "秋分の日"],
99
+ [#<Date: 2019-10-14 ((2458771j,0s,0n),+0s,2299161j)>, "体育の日"],
100
+ [#<Date: 2019-10-22 ((2458779j,0s,0n),+0s,2299161j)>, "即位礼正殿の儀"],
101
+ [#<Date: 2019-11-03 ((2458791j,0s,0n),+0s,2299161j)>, "文化の日"],
102
+ [#<Date: 2019-11-04 ((2458792j,0s,0n),+0s,2299161j)>, "振替休日"],
103
+ [#<Date: 2019-11-23 ((2458811j,0s,0n),+0s,2299161j)>, "勤労感謝の日"]]
100
104
  ```
101
105
 
102
106
  * `hash_year(year)` ― ある年について、 {日付=>祝日名} のHashを返す
103
107
 
104
108
  ```ruby
105
- HolidayJapan.hash_year(2018)
106
- => {#<Date: 2018-01-01 ((2458120j,0s,0n),+0s,2299161j)>=>"元日",
107
- #<Date: 2018-01-08 ((2458127j,0s,0n),+0s,2299161j)>=>"成人の日",
108
- #<Date: 2018-02-11 ((2458161j,0s,0n),+0s,2299161j)>=>"建国記念の日",
109
- #<Date: 2018-02-12 ((2458162j,0s,0n),+0s,2299161j)>=>"振替休日",
110
- #<Date: 2018-03-21 ((2458199j,0s,0n),+0s,2299161j)>=>"春分の日",
111
- #<Date: 2018-04-29 ((2458238j,0s,0n),+0s,2299161j)>=>"昭和の日",
112
- #<Date: 2018-04-30 ((2458239j,0s,0n),+0s,2299161j)>=>"振替休日",
113
- #<Date: 2018-05-03 ((2458242j,0s,0n),+0s,2299161j)>=>"憲法記念日",
114
- #<Date: 2018-05-04 ((2458243j,0s,0n),+0s,2299161j)>=>"みどりの日",
115
- #<Date: 2018-05-05 ((2458244j,0s,0n),+0s,2299161j)>=>"こどもの日",
116
- #<Date: 2018-07-16 ((2458316j,0s,0n),+0s,2299161j)>=>"海の日",
117
- #<Date: 2018-08-11 ((2458342j,0s,0n),+0s,2299161j)>=>"山の日",
118
- #<Date: 2018-09-17 ((2458379j,0s,0n),+0s,2299161j)>=>"敬老の日",
119
- #<Date: 2018-09-23 ((2458385j,0s,0n),+0s,2299161j)>=>"秋分の日",
120
- #<Date: 2018-09-24 ((2458386j,0s,0n),+0s,2299161j)>=>"振替休日",
121
- #<Date: 2018-10-08 ((2458400j,0s,0n),+0s,2299161j)>=>"体育の日",
122
- #<Date: 2018-11-03 ((2458426j,0s,0n),+0s,2299161j)>=>"文化の日",
123
- #<Date: 2018-11-23 ((2458446j,0s,0n),+0s,2299161j)>=>"勤労感謝の日",
124
- #<Date: 2018-12-23 ((2458476j,0s,0n),+0s,2299161j)>=>"天皇誕生日",
125
- #<Date: 2018-12-24 ((2458477j,0s,0n),+0s,2299161j)>=>"振替休日"}
109
+ HolidayJapan.hash_year(2019)
110
+ => {#<Date: 2019-01-01 ((2458485j,0s,0n),+0s,2299161j)>=>"元日",
111
+ #<Date: 2019-01-14 ((2458498j,0s,0n),+0s,2299161j)>=>"成人の日",
112
+ #<Date: 2019-02-11 ((2458526j,0s,0n),+0s,2299161j)>=>"建国記念の日",
113
+ #<Date: 2019-03-21 ((2458564j,0s,0n),+0s,2299161j)>=>"春分の日",
114
+ #<Date: 2019-04-29 ((2458603j,0s,0n),+0s,2299161j)>=>"昭和の日",
115
+ #<Date: 2019-04-30 ((2458604j,0s,0n),+0s,2299161j)>=>"国民の休日",
116
+ #<Date: 2019-05-01 ((2458605j,0s,0n),+0s,2299161j)>=>"即位の日(名称未定)",
117
+ #<Date: 2019-05-02 ((2458606j,0s,0n),+0s,2299161j)>=>"国民の休日",
118
+ #<Date: 2019-05-03 ((2458607j,0s,0n),+0s,2299161j)>=>"憲法記念日",
119
+ #<Date: 2019-05-04 ((2458608j,0s,0n),+0s,2299161j)>=>"みどりの日",
120
+ #<Date: 2019-05-05 ((2458609j,0s,0n),+0s,2299161j)>=>"こどもの日",
121
+ #<Date: 2019-05-06 ((2458610j,0s,0n),+0s,2299161j)>=>"振替休日",
122
+ #<Date: 2019-07-15 ((2458680j,0s,0n),+0s,2299161j)>=>"海の日",
123
+ #<Date: 2019-08-11 ((2458707j,0s,0n),+0s,2299161j)>=>"山の日",
124
+ #<Date: 2019-08-12 ((2458708j,0s,0n),+0s,2299161j)>=>"振替休日",
125
+ #<Date: 2019-09-16 ((2458743j,0s,0n),+0s,2299161j)>=>"敬老の日",
126
+ #<Date: 2019-09-23 ((2458750j,0s,0n),+0s,2299161j)>=>"秋分の日",
127
+ #<Date: 2019-10-14 ((2458771j,0s,0n),+0s,2299161j)>=>"体育の日",
128
+ #<Date: 2019-10-22 ((2458779j,0s,0n),+0s,2299161j)>=>"即位礼正殿の儀",
129
+ #<Date: 2019-11-03 ((2458791j,0s,0n),+0s,2299161j)>=>"文化の日",
130
+ #<Date: 2019-11-04 ((2458792j,0s,0n),+0s,2299161j)>=>"振替休日",
131
+ #<Date: 2019-11-23 ((2458811j,0s,0n),+0s,2299161j)>=>"勤労感謝の日"}
126
132
  ```
127
133
 
128
134
  * `between(from_date,to_date)` ― from_date から to_date までの祝日について、{日付=>祝日名}のHashを返す
129
135
 
130
136
  ```ruby
131
- HolidayJapan.between("2018-4-1","2019-3-31")
132
- => {#<Date: 2018-04-29 ((2458238j,0s,0n),+0s,2299161j)>=>"昭和の日",
133
- #<Date: 2018-04-30 ((2458239j,0s,0n),+0s,2299161j)>=>"振替休日",
134
- #<Date: 2018-05-03 ((2458242j,0s,0n),+0s,2299161j)>=>"憲法記念日",
135
- #<Date: 2018-05-04 ((2458243j,0s,0n),+0s,2299161j)>=>"みどりの日",
136
- #<Date: 2018-05-05 ((2458244j,0s,0n),+0s,2299161j)>=>"こどもの日",
137
- #<Date: 2018-07-16 ((2458316j,0s,0n),+0s,2299161j)>=>"海の日",
138
- #<Date: 2018-08-11 ((2458342j,0s,0n),+0s,2299161j)>=>"山の日",
139
- #<Date: 2018-09-17 ((2458379j,0s,0n),+0s,2299161j)>=>"敬老の日",
140
- #<Date: 2018-09-23 ((2458385j,0s,0n),+0s,2299161j)>=>"秋分の日",
141
- #<Date: 2018-09-24 ((2458386j,0s,0n),+0s,2299161j)>=>"振替休日",
142
- #<Date: 2018-10-08 ((2458400j,0s,0n),+0s,2299161j)>=>"体育の日",
143
- #<Date: 2018-11-03 ((2458426j,0s,0n),+0s,2299161j)>=>"文化の日",
144
- #<Date: 2018-11-23 ((2458446j,0s,0n),+0s,2299161j)>=>"勤労感謝の日",
145
- #<Date: 2018-12-23 ((2458476j,0s,0n),+0s,2299161j)>=>"天皇誕生日",
146
- #<Date: 2018-12-24 ((2458477j,0s,0n),+0s,2299161j)>=>"振替休日",
147
- #<Date: 2019-01-01 ((2458485j,0s,0n),+0s,2299161j)>=>"元日",
148
- #<Date: 2019-01-14 ((2458498j,0s,0n),+0s,2299161j)>=>"成人の日",
149
- #<Date: 2019-02-11 ((2458526j,0s,0n),+0s,2299161j)>=>"建国記念の日",
150
- #<Date: 2019-03-21 ((2458564j,0s,0n),+0s,2299161j)>=>"春分の日"}
137
+ HolidayJapan.between("2019-4-1","2020-3-31")
138
+ => {#<Date: 2019-04-29 ((2458603j,0s,0n),+0s,2299161j)>=>"昭和の日",
139
+ #<Date: 2019-04-30 ((2458604j,0s,0n),+0s,2299161j)>=>"国民の休日",
140
+ #<Date: 2019-05-01 ((2458605j,0s,0n),+0s,2299161j)>=>"即位の日(名称未定)",
141
+ #<Date: 2019-05-02 ((2458606j,0s,0n),+0s,2299161j)>=>"国民の休日",
142
+ #<Date: 2019-05-03 ((2458607j,0s,0n),+0s,2299161j)>=>"憲法記念日",
143
+ #<Date: 2019-05-04 ((2458608j,0s,0n),+0s,2299161j)>=>"みどりの日",
144
+ #<Date: 2019-05-05 ((2458609j,0s,0n),+0s,2299161j)>=>"こどもの日",
145
+ #<Date: 2019-05-06 ((2458610j,0s,0n),+0s,2299161j)>=>"振替休日",
146
+ #<Date: 2019-07-15 ((2458680j,0s,0n),+0s,2299161j)>=>"海の日",
147
+ #<Date: 2019-08-11 ((2458707j,0s,0n),+0s,2299161j)>=>"山の日",
148
+ #<Date: 2019-08-12 ((2458708j,0s,0n),+0s,2299161j)>=>"振替休日",
149
+ #<Date: 2019-09-16 ((2458743j,0s,0n),+0s,2299161j)>=>"敬老の日",
150
+ #<Date: 2019-09-23 ((2458750j,0s,0n),+0s,2299161j)>=>"秋分の日",
151
+ #<Date: 2019-10-14 ((2458771j,0s,0n),+0s,2299161j)>=>"体育の日",
152
+ #<Date: 2019-10-22 ((2458779j,0s,0n),+0s,2299161j)>=>"即位礼正殿の儀",
153
+ #<Date: 2019-11-03 ((2458791j,0s,0n),+0s,2299161j)>=>"文化の日",
154
+ #<Date: 2019-11-04 ((2458792j,0s,0n),+0s,2299161j)>=>"振替休日",
155
+ #<Date: 2019-11-23 ((2458811j,0s,0n),+0s,2299161j)>=>"勤労感謝の日",
156
+ #<Date: 2020-01-01 ((2458850j,0s,0n),+0s,2299161j)>=>"元日",
157
+ #<Date: 2020-01-13 ((2458862j,0s,0n),+0s,2299161j)>=>"成人の日",
158
+ #<Date: 2020-02-11 ((2458891j,0s,0n),+0s,2299161j)>=>"建国記念の日",
159
+ #<Date: 2020-02-23 ((2458903j,0s,0n),+0s,2299161j)>=>"天皇誕生日",
160
+ #<Date: 2020-02-24 ((2458904j,0s,0n),+0s,2299161j)>=>"振替休日",
161
+ #<Date: 2020-03-20 ((2458929j,0s,0n),+0s,2299161j)>=>"春分の日"}
151
162
  ```
152
163
 
153
164
  ### 祝日データをCSVに出力
154
165
 
155
166
  ```
156
- $ ruby -r csv -r holiday_japan -e 'CSV.open("holiday.csv","w"){|c| HolidayJapan.between(2016,2018).each{|a| c<<a}}'
157
-
167
+ $ ruby -r csv -r holiday_japan -e 'CSV.open("holiday.csv","w"){|c| HolidayJapan.between(2018,2020).each{|a| c<<a}}'
158
168
  $ head -n3 holiday.csv ; echo ...; tail -n3 holiday.csv
159
- 2016-01-01,元日
160
- 2016-01-11,成人の日
161
- 2016-02-11,建国記念の日
169
+ 2018-01-01,元日
170
+ 2018-01-08,成人の日
171
+ 2018-02-11,建国記念の日
162
172
  ...
163
- 2018-11-23,勤労感謝の日
164
- 2018-12-23,天皇誕生日
165
- 2018-12-24,振替休日
173
+ 2020-09-22,秋分の日
174
+ 2020-11-03,文化の日
175
+ 2020-11-23,勤労感謝の日
166
176
  ```
167
177
 
168
178
  ## 祝日データ
169
179
 
170
180
  * 1948年7月20日(祝日法発令) 以降の祝日に対応
171
- * 2019年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
181
+ * 2020年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
172
182
  * 春分の日・秋分の日の計算は2150年まで
173
183
 
174
184
  ## Author:
@@ -181,7 +191,7 @@
181
191
  NO WARRANTY.
182
192
 
183
193
  ## Version:
184
- 2018-04-14 ver 1.4 祝日データ仕様変更、2020年対応
194
+ 2018-04-14 ver 1.4 祝日データ仕様変更、2019,2020年対応
185
195
  2017-12-01 ver 1.3 print_between 関数追加
186
196
  2015-04-11 ver 1.2 hash_year, between 関数追加
187
197
  2014-05-23 ver 1.1 「山の日」追加
data/README.md.erb ADDED
@@ -0,0 +1,123 @@
1
+ <%
2
+ # erb -T 1 README.md.erb > README.md
3
+ require 'pp'
4
+ require 'holiday_japan'
5
+ $indent=' '
6
+
7
+ def x(sample)
8
+ a = eval(sample).pretty_inspect.each_line.to_a
9
+ [
10
+ "```ruby\n",
11
+ sample+"\n",
12
+ "=> "+a.shift,
13
+ *a.map{|x| " "+x },
14
+ "```\n"
15
+ ].map{|x| $indent+x}.join
16
+ end
17
+
18
+ def c(sample)
19
+ [
20
+ "$ "+sample+"\n",
21
+ *`#{sample}`.each_line.to_a,
22
+ ].map{|x| $indent+x}.join
23
+ end
24
+ %>
25
+ # 日本の祝日判定Rubyプログラム
26
+
27
+ ([GitHub](https://github.com/masa16/holiday_japan)),
28
+ ([RubyGems](https://rubygems.org/gems/holiday_japan))
29
+
30
+ ## 特徴
31
+ * 1948年7月20日以降の日本の国民の祝日、振替休日、および国民の休日を計算して判定。
32
+ * スクリプトコード([holiday_japan.rb](https://github.com/masa16/holiday_japan/blob/master/lib/holiday_japan.rb))は、祝日データを含めて200行弱とコンパクト。
33
+
34
+ (date2 の holiday.rb と比較して)
35
+ * 祝日をキャッシュすることにより、大量の日付について祝日判定する場合でも高速に動作
36
+ * 祝日名を返すことが可能
37
+ * 祝日のルールをテーブルで持つことにより、法改正による祝日変更への対応が容易
38
+
39
+ ## インストール
40
+
41
+ * RubyGems によるインストール
42
+ ```
43
+ gem install holiday_japan
44
+ ```
45
+
46
+ * または、[holiday_japan.rb](https://github.com/masa16/holiday_japan/blob/master/lib/holiday_japan.rb)
47
+ のスクリプトファイルを ruby のライブラリパスに置く
48
+
49
+ ## 使い方
50
+
51
+ ### モジュールをロード
52
+
53
+ ```ruby
54
+ require 'holiday_japan'
55
+ ```
56
+
57
+ ### HolidayJapan モジュール関数
58
+
59
+ * `check(date)` ― Dateクラスのオブジェクトによる祝日判定
60
+
61
+ <%= x('HolidayJapan.check(Date.new(2019,3,21))') %>
62
+
63
+ * `name(date)` ― 日付が祝日の場合は祝日名を返し、祝日でなければ nil を返す。
64
+
65
+ <%= x('HolidayJapan.name(Date.new(2019,3,21))') %>
66
+
67
+ * `print_year(year)` ― ある年の祝日一覧をプリント
68
+
69
+ ```
70
+ <%= c("ruby -r holiday_japan -e 'HolidayJapan.print_year 2019'") %>
71
+ ```
72
+
73
+ * `list_year(year)` ― ある年について、 [日付, 祝日名] のArrayを返す
74
+
75
+ <%= x('HolidayJapan.list_year(2019)') %>
76
+
77
+ * `hash_year(year)` ― ある年について、 {日付=>祝日名} のHashを返す
78
+
79
+ <%= x('HolidayJapan.hash_year(2019)') %>
80
+
81
+ * `between(from_date,to_date)` ― from_date から to_date までの祝日について、{日付=>祝日名}のHashを返す
82
+
83
+ <%= x('HolidayJapan.between("2019-4-1","2020-3-31")') %>
84
+
85
+ ### 祝日データをCSVに出力
86
+
87
+ ```
88
+ <%= c(%!ruby -r csv -r holiday_japan -e 'CSV.open("holiday.csv","w"){|c| HolidayJapan.between(2018,2020).each{|a| c<<a}}'!) %>
89
+ <%= c("head -n3 holiday.csv ; echo ...; tail -n3 holiday.csv") %>
90
+ ```
91
+
92
+ ## 祝日データ
93
+
94
+ * 1948年7月20日(祝日法発令) 以降の祝日に対応
95
+ * 2020年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
96
+ * 春分の日・秋分の日の計算は2150年まで
97
+
98
+ ## Author:
99
+ Masahiro TANAKA
100
+
101
+ ## Copyright:
102
+ (C) Copyright 2003-2018 by Masahiro TANAKA
103
+ This program is free software under MIT license.
104
+ See LICENSE.txt.
105
+ NO WARRANTY.
106
+
107
+ ## Version:
108
+ 2018-04-14 ver 1.4 祝日データ仕様変更、2019,2020年対応
109
+ 2017-12-01 ver 1.3 print_between 関数追加
110
+ 2015-04-11 ver 1.2 hash_year, between 関数追加
111
+ 2014-05-23 ver 1.1 「山の日」追加
112
+ 2012-12-23 ver 1.0 モジュール名を Holiday から HolidayJapan に変更
113
+ 2007-08-02 ver 0.9 リファクタリング
114
+ 2007-03-08 ver 0.8 祝日データクラスを統一、データを配列で記述
115
+ 2006-02-06 ver 0.7 平成19年(西暦2007年)の暦要項 反映(祝日法改正)
116
+ Holiday.create_table 修正
117
+ Holiday.list_year 追加
118
+ 2003-10-02 ver 0.6 祝日データ追加
119
+ 2003-09-29 ver 0.5
120
+ 2003-09-22 ver 0.4
121
+ 2003-09-20 ver 0.3
122
+ 2003-09-16 ver 0.2
123
+ 2003-09-15 ver 0.1
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :readme do
4
+ sh "erb -T 1 README.md.erb > README.md"
5
+ end
data/lib/holiday_japan.rb CHANGED
@@ -6,7 +6,7 @@ require "date"
6
6
 
7
7
  module HolidayJapan
8
8
 
9
- VERSION = "1.4.2"
9
+ VERSION = "1.4.3"
10
10
 
11
11
  WEEK1 = 1
12
12
  WEEK2 = 8
@@ -54,7 +54,7 @@ module HolidayJapan
54
54
  ],
55
55
  ["即位礼正殿の儀", [2019, 10, 22 ],
56
56
  [1990, 11, 12 ]],
57
- ["即位の日(名称未定)", [2019, 5, 1 ]],
57
+ ["天皇の即位の日", [2019, 5, 1 ]],
58
58
  ["皇太子徳仁親王の結婚の儀", [1993, 6, 9 ]],
59
59
  ["昭和天皇の大喪の礼", [1989, 2, 24 ]],
60
60
  ["皇太子明仁親王の結婚の儀", [1959, 4, 10 ]]
data/test/holiday.csv CHANGED
@@ -979,3 +979,21 @@
979
979
  2019-11-03,文化の日
980
980
  2019-11-04,振替休日
981
981
  2019-11-23,勤労感謝の日
982
+ 2020-01-01,元日
983
+ 2020-01-13,成人の日
984
+ 2020-02-11,建国記念の日
985
+ 2020-02-23,天皇誕生日
986
+ 2020-02-24,振替休日
987
+ 2020-03-20,春分の日
988
+ 2020-04-29,昭和の日
989
+ 2020-05-03,憲法記念日
990
+ 2020-05-04,みどりの日
991
+ 2020-05-05,こどもの日
992
+ 2020-05-06,振替休日
993
+ 2020-07-23,海の日
994
+ 2020-07-24,スポーツの日
995
+ 2020-08-10,山の日
996
+ 2020-09-21,敬老の日
997
+ 2020-09-22,秋分の日
998
+ 2020-11-03,文化の日
999
+ 2020-11-23,勤労感謝の日
@@ -3,7 +3,7 @@ require "holiday_japan"
3
3
  require "csv"
4
4
 
5
5
  $first_year = 1948
6
- $last_year = 2019
6
+ $last_year = 2020
7
7
  $range = $first_year..$last_year
8
8
  $csv_file = File.join(__dir__,"holiday.csv")
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holiday_japan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2019-03-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calculate National Holidays of Japan after 1948
14
14
  email:
@@ -21,6 +21,7 @@ files:
21
21
  - Gemfile
22
22
  - LICENSE.txt
23
23
  - README.md
24
+ - README.md.erb
24
25
  - Rakefile
25
26
  - holiday_japan.gemspec
26
27
  - lib/holiday_japan.rb
@@ -45,8 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
48
  requirements: []
48
- rubyforge_project:
49
- rubygems_version: 2.7.8
49
+ rubygems_version: 3.0.1
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: Calculate National Holidays of Japan