holiday_japan 1.2.4 → 1.2.5

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 +17 -2
  3. data/lib/holiday_japan.rb +4 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ade8c869f5e1140a5bdc6e49c14ea7515962372
4
- data.tar.gz: c75e594c7d61cf4419be9651f8539dd357e19dc5
3
+ metadata.gz: 480678c4f9d133e1c3e1f00b3c9f2ae243c2ea61
4
+ data.tar.gz: 898a499852f5c0d021c195e8be2b0348ac5b3a7d
5
5
  SHA512:
6
- metadata.gz: 9640372d264395f1218f2cac441bdaebb799b8b1bd9ca03bf2701909e592dcf28e27a1cd136c99c9e2e157839a262ee141d2a45a5d4b39953c06f35db5842cf9
7
- data.tar.gz: 3a5fd468354edb45f26ee7a0a4d2895479fdd676a0ac8a9f1c4318306728db5933844b1667f65a6791528cdfd475cfee94d713d1d2e066ff8381eaccaf08df52
6
+ metadata.gz: 23bc99e34b78d3dae93c091cc04670f72384ef75e2919771b83d6c2c79204cc68a5595f37af759648d7988acd0940ba69c6e486809d78d70fedba323745c9b9d
7
+ data.tar.gz: 66b1d2337908784e4f73641c20588ee28d59b28a67565e5ac40854a576acc416213893448910943db317add1578658eefab3140529e9f185a57f29a7046035b2
data/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  ## 使い方
25
25
 
26
- * holiday_japan.rb をロードする
26
+ ### モジュールをロード
27
27
 
28
28
  ```ruby
29
29
  require 'holiday_japan'
@@ -138,7 +138,22 @@
138
138
  #<Date: 2018-02-12 ((2458162j,0s,0n),+0s,2299161j)>=>"振替休日"}
139
139
  ```
140
140
 
141
- ## 祝日データ
141
+ ### 祝日データをCSVに出力
142
+
143
+ ```
144
+ $ ruby -r csv -r holiday_japan -e 'CSV.open("holiday.csv","w"){|c| HolidayJapan.between(2016,2018).each{|a| c<<a}}'
145
+
146
+ $ head -n3 holiday.csv ; echo ...; tail -n3 holiday.csv
147
+ 2016-01-01,元日
148
+ 2016-01-11,成人の日
149
+ 2016-02-11,建国記念の日
150
+ ...
151
+ 2018-11-23,勤労感謝の日
152
+ 2018-12-23,天皇誕生日
153
+ 2018-12-24,振替休日
154
+ ```
155
+
156
+ ## 祝日データ
142
157
 
143
158
  * 1948年7月20日(祝日法発令) 以降の祝日に対応
144
159
  * 2018年の[暦要項](http://eco.mtk.nao.ac.jp/koyomi/yoko/)まで確認(法改正がない限り以降も有効)
data/lib/holiday_japan.rb CHANGED
@@ -6,7 +6,7 @@ require "date"
6
6
 
7
7
  module HolidayJapan
8
8
 
9
- VERSION = "1.2.4"
9
+ VERSION = "1.2.5"
10
10
 
11
11
  WEEK1 = 1
12
12
  WEEK2 = 8
@@ -112,7 +112,7 @@ module HolidayJapan
112
112
  end
113
113
  end
114
114
  end
115
- h.freeze
115
+ Hash[h.sort_by{|d,| d}].freeze
116
116
  end
117
117
 
118
118
  def name(date)
@@ -135,6 +135,8 @@ module HolidayJapan
135
135
  end
136
136
 
137
137
  def between(from_date,to_date)
138
+ from_date = Date.new(from_date,1,1) if from_date.kind_of?(Integer)
139
+ to_date = Date.new(to_date,12,31) if to_date.kind_of?(Integer)
138
140
  if from_date > to_date
139
141
  raise ArgumentError, "to_date is earlier than from_date"
140
142
  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.4
4
+ version: 1.2.5
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-02-15 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calculate National Holidays of Japan between 1948..2150
14
14
  email: