holiday_japan 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -106
  3. data/lib/holiday_japan.rb +8 -5
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 867527a26b8126f7719f9b8c722b3768e0e88c74
4
- data.tar.gz: 5802282ae981d997c06b732c09ae7cf1928fe514
3
+ metadata.gz: 9ade8c869f5e1140a5bdc6e49c14ea7515962372
4
+ data.tar.gz: c75e594c7d61cf4419be9651f8539dd357e19dc5
5
5
  SHA512:
6
- metadata.gz: 2bd7a06035156dc216eed51b77ca31ac4fc533dbbcdbac215c62b9b433548c634995b24238c5300de399f9ca42472f86e31f86a4c9445fad30062f24f59d802f
7
- data.tar.gz: 234f7ccbaf9bd0d8303fcdcb140a04f9cfde739540b67eebefc36d46ba454a0389e679ec7bbe1d50e2784e419dc772db60b9dd8c03817aa62aab85f345c8a7d6
6
+ metadata.gz: 9640372d264395f1218f2cac441bdaebb799b8b1bd9ca03bf2701909e592dcf28e27a1cd136c99c9e2e157839a262ee141d2a45a5d4b39953c06f35db5842cf9
7
+ data.tar.gz: 3a5fd468354edb45f26ee7a0a4d2895479fdd676a0ac8a9f1c4318306728db5933844b1667f65a6791528cdfd475cfee94d713d1d2e066ff8381eaccaf08df52
data/README.md CHANGED
@@ -32,145 +32,123 @@
32
32
  ### HolidayJapan モジュール関数
33
33
 
34
34
  * `check(date)` ― Dateクラスのオブジェクトによる祝日判定
35
+
35
36
  ```ruby
36
- HolidayJapan.check(Date.new(2015,3,21))
37
+ HolidayJapan.check(Date.new(2017,3,20))
37
38
  => true
38
39
  ```
39
40
 
40
41
  * `name(date)` ― 日付が祝日の場合は祝日名を返し、祝日でなければ nil を返す。
42
+
41
43
  ```ruby
42
- HolidayJapan.name(Date.new(2015,3,21))
44
+ HolidayJapan.name(Date.new(2017,3,20))
43
45
  => "春分の日"
44
46
  ```
45
47
 
46
- * `list_year(year)` ― ある年について、 [日付, 祝日名] のArrayを返す
48
+ * `print_year(year)` ― ある年の祝日一覧をプリント
47
49
 
48
- ```ruby
49
- HolidayJapan.list_year(2015)
50
- => [[#<Date: 2015-01-01>, "元日"],
51
- [#<Date: 2015-01-12>, "成人の日"],
52
- [#<Date: 2015-02-11>, "建国記念の日"],
53
- [#<Date: 2015-03-21>, "春分の日"],
54
- [#<Date: 2015-04-29>, "昭和の日"],
55
- [#<Date: 2015-05-03>, "憲法記念日"],
56
- [#<Date: 2015-05-04>, "みどりの日"],
57
- [#<Date: 2015-05-05>, "こどもの日"],
58
- [#<Date: 2015-05-06>, "振替休日"],
59
- [#<Date: 2015-07-20>, "海の日"],
60
- [#<Date: 2015-09-21>, "敬老の日"],
61
- [#<Date: 2015-09-22>, "国民の休日"],
62
- [#<Date: 2015-09-23>, "秋分の日"],
63
- [#<Date: 2015-10-12>, "体育の日"],
64
- [#<Date: 2015-11-03>, "文化の日"],
65
- [#<Date: 2015-11-23>, "勤労感謝の日"],
66
- [#<Date: 2015-12-23>, "天皇誕生日"]]
50
+ ```
51
+ $ ruby -r holiday_japan -e 'HolidayJapan.print_year 2017'
52
+ listing year 2017...
53
+ 2017-01-01 Sun 元日
54
+ 2017-01-02 Mon 振替休日
55
+ 2017-01-09 Mon 成人の日
56
+ 2017-02-11 Sat 建国記念の日
57
+ 2017-03-20 Mon 春分の日
58
+ 2017-04-29 Sat 昭和の日
59
+ 2017-05-03 Wed 憲法記念日
60
+ 2017-05-04 Thu みどりの日
61
+ 2017-05-05 Fri こどもの日
62
+ 2017-07-17 Mon 海の日
63
+ 2017-08-11 Fri 山の日
64
+ 2017-09-18 Mon 敬老の日
65
+ 2017-09-23 Sat 秋分の日
66
+ 2017-10-09 Mon 体育の日
67
+ 2017-11-03 Fri 文化の日
68
+ 2017-11-23 Thu 勤労感謝の日
69
+ 2017-12-23 Sat 天皇誕生日
67
70
  ```
68
71
 
69
- * `hash_year(year)` ― ある年について、 {日付=>祝日名}Hashを返す
72
+ * `list_year(year)` ― ある年について、 [日付, 祝日名] Arrayを返す
70
73
 
71
74
  ```ruby
72
- HolidayJapan.hash_year(2015)
73
- => {#<Date: 2015-01-01>=>"元日",
74
- #<Date: 2015-01-12>=>"成人の日",
75
- #<Date: 2015-02-11>=>"建国記念の日",
76
- #<Date: 2015-04-29>=>"昭和の日",
77
- #<Date: 2015-05-03>=>"憲法記念日",
78
- #<Date: 2015-05-04>=>"みどりの日",
79
- #<Date: 2015-05-05>=>"こどもの日",
80
- #<Date: 2015-07-20>=>"海の日",
81
- #<Date: 2015-09-21>=>"敬老の日",
82
- #<Date: 2015-10-12>=>"体育の日",
83
- #<Date: 2015-11-03>=>"文化の日",
84
- #<Date: 2015-11-23>=>"勤労感謝の日",
85
- #<Date: 2015-12-23>=>"天皇誕生日",
86
- #<Date: 2015-03-21>=>"春分の日",
87
- #<Date: 2015-09-23>=>"秋分の日",
88
- #<Date: 2015-05-06>=>"振替休日",
89
- #<Date: 2015-09-22>=>"国民の休日"}
75
+ HolidayJapan.list_year(2017)
76
+ => [[#<Date: 2017-01-01 ((2457755j,0s,0n),+0s,2299161j)>, "元日"],
77
+ [#<Date: 2017-01-02 ((2457756j,0s,0n),+0s,2299161j)>, "振替休日"],
78
+ [#<Date: 2017-01-09 ((2457763j,0s,0n),+0s,2299161j)>, "成人の日"],
79
+ [#<Date: 2017-02-11 ((2457796j,0s,0n),+0s,2299161j)>, "建国記念の日"],
80
+ [#<Date: 2017-03-20 ((2457833j,0s,0n),+0s,2299161j)>, "春分の日"],
81
+ [#<Date: 2017-04-29 ((2457873j,0s,0n),+0s,2299161j)>, "昭和の日"],
82
+ [#<Date: 2017-05-03 ((2457877j,0s,0n),+0s,2299161j)>, "憲法記念日"],
83
+ [#<Date: 2017-05-04 ((2457878j,0s,0n),+0s,2299161j)>, "みどりの日"],
84
+ [#<Date: 2017-05-05 ((2457879j,0s,0n),+0s,2299161j)>, "こどもの日"],
85
+ [#<Date: 2017-07-17 ((2457952j,0s,0n),+0s,2299161j)>, "海の日"],
86
+ [#<Date: 2017-08-11 ((2457977j,0s,0n),+0s,2299161j)>, "山の日"],
87
+ [#<Date: 2017-09-18 ((2458015j,0s,0n),+0s,2299161j)>, "敬老の日"],
88
+ [#<Date: 2017-09-23 ((2458020j,0s,0n),+0s,2299161j)>, "秋分の日"],
89
+ [#<Date: 2017-10-09 ((2458036j,0s,0n),+0s,2299161j)>, "体育の日"],
90
+ [#<Date: 2017-11-03 ((2458061j,0s,0n),+0s,2299161j)>, "文化の日"],
91
+ [#<Date: 2017-11-23 ((2458081j,0s,0n),+0s,2299161j)>, "勤労感謝の日"],
92
+ [#<Date: 2017-12-23 ((2458111j,0s,0n),+0s,2299161j)>, "天皇誕生日"]]
90
93
  ```
91
94
 
92
- * `between(from_date,to_date)` ― from_date から to_date までの祝日について、{日付=>祝日名}のHashを返す
95
+ * `hash_year(year)` ― ある年について、 {日付=>祝日名} のHashを返す
93
96
 
94
97
  ```ruby
95
- HolidayJapan.between(Date.new(2014,7,1),Date.new(2015,6,30))
96
- => {#<Date: 2014-07-21>=>"海の日",
97
- #<Date: 2014-09-15>=>"敬老の日",
98
- #<Date: 2014-10-13>=>"体育の日",
99
- #<Date: 2014-11-03>=>"文化の日",
100
- #<Date: 2014-11-23>=>"勤労感謝の日",
101
- #<Date: 2014-12-23>=>"天皇誕生日",
102
- #<Date: 2014-09-23>=>"秋分の日",
103
- #<Date: 2014-11-24>=>"振替休日",
104
- #<Date: 2015-01-01>=>"元日",
105
- #<Date: 2015-01-12>=>"成人の日",
106
- #<Date: 2015-02-11>=>"建国記念の日",
107
- #<Date: 2015-04-29>=>"昭和の日",
108
- #<Date: 2015-05-03>=>"憲法記念日",
109
- #<Date: 2015-05-04>=>"みどりの日",
110
- #<Date: 2015-05-05>=>"こどもの日",
111
- #<Date: 2015-03-21>=>"春分の日",
112
- #<Date: 2015-05-06>=>"振替休日"}
98
+ HolidayJapan.hash_year(2017)
99
+ => {#<Date: 2017-01-01 ((2457755j,0s,0n),+0s,2299161j)>=>"元日",
100
+ #<Date: 2017-01-09 ((2457763j,0s,0n),+0s,2299161j)>=>"成人の日",
101
+ #<Date: 2017-02-11 ((2457796j,0s,0n),+0s,2299161j)>=>"建国記念の日",
102
+ #<Date: 2017-04-29 ((2457873j,0s,0n),+0s,2299161j)>=>"昭和の日",
103
+ #<Date: 2017-05-03 ((2457877j,0s,0n),+0s,2299161j)>=>"憲法記念日",
104
+ #<Date: 2017-05-04 ((2457878j,0s,0n),+0s,2299161j)>=>"みどりの日",
105
+ #<Date: 2017-05-05 ((2457879j,0s,0n),+0s,2299161j)>=>"こどもの日",
106
+ #<Date: 2017-07-17 ((2457952j,0s,0n),+0s,2299161j)>=>"海の日",
107
+ #<Date: 2017-08-11 ((2457977j,0s,0n),+0s,2299161j)>=>"山の日",
108
+ #<Date: 2017-09-18 ((2458015j,0s,0n),+0s,2299161j)>=>"敬老の日",
109
+ #<Date: 2017-10-09 ((2458036j,0s,0n),+0s,2299161j)>=>"体育の日",
110
+ #<Date: 2017-11-03 ((2458061j,0s,0n),+0s,2299161j)>=>"文化の日",
111
+ #<Date: 2017-11-23 ((2458081j,0s,0n),+0s,2299161j)>=>"勤労感謝の日",
112
+ #<Date: 2017-12-23 ((2458111j,0s,0n),+0s,2299161j)>=>"天皇誕生日",
113
+ #<Date: 2017-03-20 ((2457833j,0s,0n),+0s,2299161j)>=>"春分の日",
114
+ #<Date: 2017-09-23 ((2458020j,0s,0n),+0s,2299161j)>=>"秋分の日",
115
+ #<Date: 2017-01-02 ((2457756j,0s,0n),+0s,2299161j)>=>"振替休日"}
113
116
  ```
114
117
 
115
- * `print_year(year)` ― ある年の祝日一覧をプリント
118
+ * `between(from_date,to_date)` ― from_date から to_date までの祝日について、{日付=>祝日名}のHashを返す
116
119
 
117
120
  ```ruby
118
- HolidayJapan.print_year(2015)
121
+ HolidayJapan.between(Date.new(2017,4,1),Date.new(2018,3,31))
122
+ => {#<Date: 2017-04-29 ((2457873j,0s,0n),+0s,2299161j)>=>"昭和の日",
123
+ #<Date: 2017-05-03 ((2457877j,0s,0n),+0s,2299161j)>=>"憲法記念日",
124
+ #<Date: 2017-05-04 ((2457878j,0s,0n),+0s,2299161j)>=>"みどりの日",
125
+ #<Date: 2017-05-05 ((2457879j,0s,0n),+0s,2299161j)>=>"こどもの日",
126
+ #<Date: 2017-07-17 ((2457952j,0s,0n),+0s,2299161j)>=>"海の日",
127
+ #<Date: 2017-08-11 ((2457977j,0s,0n),+0s,2299161j)>=>"山の日",
128
+ #<Date: 2017-09-18 ((2458015j,0s,0n),+0s,2299161j)>=>"敬老の日",
129
+ #<Date: 2017-10-09 ((2458036j,0s,0n),+0s,2299161j)>=>"体育の日",
130
+ #<Date: 2017-11-03 ((2458061j,0s,0n),+0s,2299161j)>=>"文化の日",
131
+ #<Date: 2017-11-23 ((2458081j,0s,0n),+0s,2299161j)>=>"勤労感謝の日",
132
+ #<Date: 2017-12-23 ((2458111j,0s,0n),+0s,2299161j)>=>"天皇誕生日",
133
+ #<Date: 2017-09-23 ((2458020j,0s,0n),+0s,2299161j)>=>"秋分の日",
134
+ #<Date: 2018-01-01 ((2458120j,0s,0n),+0s,2299161j)>=>"元日",
135
+ #<Date: 2018-01-08 ((2458127j,0s,0n),+0s,2299161j)>=>"成人の日",
136
+ #<Date: 2018-02-11 ((2458161j,0s,0n),+0s,2299161j)>=>"建国記念の日",
137
+ #<Date: 2018-03-21 ((2458199j,0s,0n),+0s,2299161j)>=>"春分の日",
138
+ #<Date: 2018-02-12 ((2458162j,0s,0n),+0s,2299161j)>=>"振替休日"}
119
139
  ```
120
- ```
121
- listing year 2015...
122
- 2015-01-01 Thu 元日
123
- 2015-01-12 Mon 成人の日
124
- 2015-02-11 Wed 建国記念の日
125
- 2015-03-21 Sat 春分の日
126
- 2015-04-29 Wed 昭和の日
127
- 2015-05-03 Sun 憲法記念日
128
- 2015-05-04 Mon みどりの日
129
- 2015-05-05 Tue こどもの日
130
- 2015-05-06 Wed 振替休日
131
- 2015-07-20 Mon 海の日
132
- 2015-09-21 Mon 敬老の日
133
- 2015-09-22 Tue 国民の休日
134
- 2015-09-23 Wed 秋分の日
135
- 2015-10-12 Mon 体育の日
136
- 2015-11-03 Tue 文化の日
137
- 2015-11-23 Mon 勤労感謝の日
138
- 2015-12-23 Wed 天皇誕生日
139
- ```
140
-
141
- ## コマンドラインから祝日一覧を表示
142
-
143
- $ ruby -r holiday_japan -e 'HolidayJapan.print_year 2016'
144
- listing year 2016...
145
- 2016-01-01 Fri 元日
146
- 2016-01-11 Mon 成人の日
147
- 2016-02-11 Thu 建国記念の日
148
- 2016-03-20 Sun 春分の日
149
- 2016-03-21 Mon 振替休日
150
- 2016-04-29 Fri 昭和の日
151
- 2016-05-03 Tue 憲法記念日
152
- 2016-05-04 Wed みどりの日
153
- 2016-05-05 Thu こどもの日
154
- 2016-07-18 Mon 海の日
155
- 2016-08-11 Thu 山の日
156
- 2016-09-19 Mon 敬老の日
157
- 2016-09-22 Thu 秋分の日
158
- 2016-10-10 Mon 体育の日
159
- 2016-11-03 Thu 文化の日
160
- 2016-11-23 Wed 勤労感謝の日
161
- 2016-12-23 Fri 天皇誕生日
162
140
 
163
141
  ## 祝日データ
164
142
 
165
143
  * 1948年7月20日(祝日法発令) 以降の祝日に対応
166
- * 2017年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
144
+ * 2018年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
167
145
  * 春分の日・秋分の日の計算は2150年まで
168
146
 
169
147
  ## Author:
170
148
  Masahiro TANAKA
171
149
 
172
150
  ## Copyright:
173
- (C) Copyright 2003-2015 by Masahiro TANAKA
151
+ (C) Copyright 2003-2017 by Masahiro TANAKA
174
152
  This program is free software under MIT license.
175
153
  See LICENSE.txt.
176
154
  NO WARRANTY.
@@ -1,12 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
- # (C) Copyright 2003-2015 by Masahiro TANAKA
2
+ # (C) Copyright 2003-2017 by Masahiro TANAKA
3
3
  # This program is free software under MIT license.
4
4
  # NO WARRANTY.
5
5
  require "date"
6
6
 
7
7
  module HolidayJapan
8
8
 
9
- VERSION = "1.2.3"
9
+ VERSION = "1.2.4"
10
10
 
11
11
  WEEK1 = 1
12
12
  WEEK2 = 8
@@ -21,6 +21,7 @@ module HolidayJapan
21
21
  ["成人の日", 1949..1999, 1, 15 ],
22
22
  ["成人の日", 2000..INF , 1, WEEK2, MON ],
23
23
  ["建国記念の日",1967..INF , 2, 11 ],
24
+ ["天皇誕生日", 2019..INF , 2, 23 ],
24
25
  ["天皇誕生日", 1949..1988, 4, 29 ],
25
26
  ["みどりの日", 1989..2006, 4, 29 ],
26
27
  ["昭和の日", 2007..INF , 4, 29 ],
@@ -36,7 +37,7 @@ module HolidayJapan
36
37
  ["体育の日", 2000..INF , 10, WEEK2, MON ],
37
38
  ["文化の日", 1948..INF , 11, 3 ],
38
39
  ["勤労感謝の日",1948..INF , 11, 23 ],
39
- ["天皇誕生日", 1989..INF , 12, 23 ],
40
+ ["天皇誕生日", 1989..2018, 12, 23 ],
40
41
  ["春分の日", 1949..1979, 3,
41
42
  proc{|y|Integer(20.8357+0.242194*(y-1980))-Integer((y-1983)/4.0)} ],
42
43
  ["春分の日", 1980..2099, 3,
@@ -62,7 +63,7 @@ module HolidayJapan
62
63
  module_function
63
64
 
64
65
  def holiday_date(year,data)
65
- name,year_range,mon,day,wday = data
66
+ year_range,mon,day,wday = data[1..4]
66
67
  if year_range === year
67
68
  case day
68
69
  when Integer
@@ -186,7 +187,9 @@ if __FILE__ == $0
186
187
  begin
187
188
  arg = eval(ARGV[0])
188
189
  rescue
189
- raise ArgumentError,"invalid argument : #{ARGV[0]}"
190
+ raise ArgumentError,"invalid argument : #{ARGV[0].inspect}
191
+ usage:
192
+ ruby holiday_japan.rb year"
190
193
  end
191
194
  HolidayJapan.print_year(arg)
192
195
  end
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.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-07 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calculate National Holidays of Japan between 1948..2150
14
14
  email: