holiday_japan 1.2.2 → 1.2.3

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 +2 -1
  3. data/lib/holiday_japan.rb +42 -25
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9540283004068cd99eab88dd20123e9f488f97ea
4
- data.tar.gz: 0ea0c38cab28e850c8fea2468d08a28294d65619
3
+ metadata.gz: 867527a26b8126f7719f9b8c722b3768e0e88c74
4
+ data.tar.gz: 5802282ae981d997c06b732c09ae7cf1928fe514
5
5
  SHA512:
6
- metadata.gz: 1187af861c7a00fcc313aa3e234093af659c9d31130c3498480e15334b5a56e67a0b3100047da9c5edd43c3646ac9012ce5d20a4d49e2581a25621a8adbaf490
7
- data.tar.gz: a8047ccd3ef055af57c1020510f7d018beb9775e6a2eed91aa64762bad0c9f7f90ca8cec6bd96b1e6b304a86bd4cf2e33790cca79265dc0d4dfa89be4d1b7973
6
+ metadata.gz: 2bd7a06035156dc216eed51b77ca31ac4fc533dbbcdbac215c62b9b433548c634995b24238c5300de399f9ca42472f86e31f86a4c9445fad30062f24f59d802f
7
+ data.tar.gz: 234f7ccbaf9bd0d8303fcdcb140a04f9cfde739540b67eebefc36d46ba454a0389e679ec7bbe1d50e2784e419dc772db60b9dd8c03817aa62aab85f345c8a7d6
data/README.md CHANGED
@@ -163,7 +163,8 @@
163
163
  ## 祝日データ
164
164
 
165
165
  * 1948年7月20日(祝日法発令) 以降の祝日に対応
166
- * 2016年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
166
+ * 2017年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
167
+ * 春分の日・秋分の日の計算は2150年まで
167
168
 
168
169
  ## Author:
169
170
  Masahiro TANAKA
data/lib/holiday_japan.rb CHANGED
@@ -6,12 +6,12 @@ require "date"
6
6
 
7
7
  module HolidayJapan
8
8
 
9
- VERSION = "1.2.2"
9
+ VERSION = "1.2.3"
10
10
 
11
- WEEK1 = 1..7
12
- WEEK2 = 8..14
13
- WEEK3 = 15..21
14
- WEEK4 = 22..28
11
+ WEEK1 = 1
12
+ WEEK2 = 8
13
+ WEEK3 = 15
14
+ WEEK4 = 22
15
15
  SUN,MON,TUE,WED,THU,FRU,SAT = (0..6).to_a
16
16
  INF = (defined? Float::INFINITY) ? Float::INFINITY : 1e34
17
17
 
@@ -38,17 +38,17 @@ module HolidayJapan
38
38
  ["勤労感謝の日",1948..INF , 11, 23 ],
39
39
  ["天皇誕生日", 1989..INF , 12, 23 ],
40
40
  ["春分の日", 1949..1979, 3,
41
- proc{|y|Integer(20.8357+0.242194*(y-1980))-Integer((y-1983)/4.0)} ],
41
+ proc{|y|Integer(20.8357+0.242194*(y-1980))-Integer((y-1983)/4.0)} ],
42
42
  ["春分の日", 1980..2099, 3,
43
- proc{|y|Integer(20.8431+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
43
+ proc{|y|Integer(20.8431+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
44
44
  ["春分の日", 2100..2150, 3,
45
- proc{|y|Integer(21.8510+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
45
+ proc{|y|Integer(21.8510+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
46
46
  ["秋分の日" , 1948..1979, 9,
47
- proc{|y|Integer(23.2588+0.242194*(y-1980))-Integer((y-1983)/4.0)} ],
47
+ proc{|y|Integer(23.2588+0.242194*(y-1980))-Integer((y-1983)/4.0)} ],
48
48
  ["秋分の日" , 1980..2099, 9,
49
- proc{|y|Integer(23.2488+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
49
+ proc{|y|Integer(23.2488+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
50
50
  ["秋分の日" , 2100..2150, 9,
51
- proc{|y|Integer(24.2488+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
51
+ proc{|y|Integer(24.2488+0.242194*(y-1980))-Integer((y-1980)/4.0)} ],
52
52
  ["皇太子明仁親王の結婚の儀", 1959..1959, 4, 10 ],
53
53
  ["昭和天皇の大喪の礼", 1989..1989, 2, 24 ],
54
54
  ["即位礼正殿の儀", 1990..1990, 11, 12 ],
@@ -65,13 +65,15 @@ module HolidayJapan
65
65
  name,year_range,mon,day,wday = data
66
66
  if year_range === year
67
67
  case day
68
- when Fixnum
69
- Date.new( year, mon, day )
70
- when Range
71
- wday0 = Date.new(year,mon,day.first).wday
72
- Date.new( year, mon, day.first+(wday-wday0+7)%7 )
68
+ when Integer
69
+ if wday
70
+ wday0 = Date.new(year,mon,day).wday
71
+ Date.new( year, mon, day+(wday-wday0+7)%7 )
72
+ else
73
+ Date.new( year, mon, day )
74
+ end
73
75
  when Proc
74
- Date.new( year, mon, day.call(year) )
76
+ Date.new( year, mon, day.call(year) )
75
77
  end
76
78
  end
77
79
  end
@@ -83,22 +85,22 @@ module HolidayJapan
83
85
  DATA.each do |x|
84
86
  if d = holiday_date(y,x)
85
87
  h[d] = x[0]
86
- a << d
88
+ a << d
87
89
  end
88
90
  end
89
91
  # compensating holiday
90
92
  if y >= 2007
91
93
  a.each do |d|
92
94
  if d.wday==SUN
93
- d+=1 while h[d]
94
- h[d] = "振替休日"
95
- end
95
+ d+=1 while h[d]
96
+ h[d] = "振替休日"
97
+ end
96
98
  end
97
99
  elsif y >= 1973
98
100
  a.each do |d|
99
101
  if d.wday==SUN and d>=FURIKAE_START
100
- h[d+1] = "振替休日"
101
- end
102
+ h[d+1] = "振替休日"
103
+ end
102
104
  end
103
105
  end
104
106
  # consecutive holiday
@@ -151,13 +153,23 @@ module HolidayJapan
151
153
  result
152
154
  end
153
155
 
154
- def print_year(year)
156
+ def _print_year(year)
155
157
  puts "listing year #{year}..."
156
158
  list_year(year).each do |y|
157
159
  puts "#{y[0].strftime('%Y-%m-%d %a')} #{y[1]}"
158
160
  end
159
161
  end
160
162
 
163
+ def print_year(year)
164
+ case year
165
+ when Range
166
+ year.each do |y|
167
+ _print_year(y)
168
+ end
169
+ else
170
+ _print_year(year)
171
+ end
172
+ end
161
173
  end
162
174
 
163
175
 
@@ -171,5 +183,10 @@ end
171
183
  # command line
172
184
  if __FILE__ == $0
173
185
  # print holiday list of the year
174
- HolidayJapan.print_year(ARGV[0])
186
+ begin
187
+ arg = eval(ARGV[0])
188
+ rescue
189
+ raise ArgumentError,"invalid argument : #{ARGV[0]}"
190
+ end
191
+ HolidayJapan.print_year(arg)
175
192
  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.2
4
+ version: 1.2.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: 2016-01-31 00:00:00.000000000 Z
11
+ date: 2017-01-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calculate National Holidays of Japan between 1948..2150
14
14
  email:
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubyforge_project:
47
- rubygems_version: 2.5.1
47
+ rubygems_version: 2.6.8
48
48
  signing_key:
49
49
  specification_version: 4
50
50
  summary: Calculate National Holidays of Japan