holidays_in_month 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/holidays_in_month/version.rb +1 -1
- data/lib/holidays_in_month.rb +28 -27
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d975839586892b78cfae940d01070bbdc9505a28
|
|
4
|
+
data.tar.gz: c21a647aadf470be2ed97d869c91af235a916169
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58be1c67e9e82fa4b54684fbf352c9e20397e26f3289a872053c938b4f75023d15770831240bde97a47c93317213dfae2cad1780a8efdcf9c67d29a354773de1
|
|
7
|
+
data.tar.gz: 2c16ad072faaef045880b54e8322186eba264f09e12f691f0739d65821fc8e298460510923835e52424c4be893e830ea61cccae08dba1328793ba549ce42e987
|
data/lib/holidays_in_month.rb
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
module JP
|
|
2
|
+
class Holidays
|
|
3
|
+
def initialize
|
|
4
|
+
@nationaldays = {}
|
|
5
|
+
@holidays = []
|
|
6
|
+
end
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
def in_month(year, month)
|
|
9
|
+
holidays(year, month) << nationaldays.select { |n| n.match(/#{year}-#{"%02d" % month}-*/) }
|
|
10
|
+
end
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
private
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
def nationaldays
|
|
15
|
+
yaml = YAML.load_file(File.expand_path('./../../holidays.yml', __FILE__))
|
|
16
|
+
yaml.each do |date, name|
|
|
17
|
+
@nationaldays.store(date.strftime("%Y-%m-%d"), name)
|
|
18
|
+
end
|
|
19
|
+
@nationaldays
|
|
17
20
|
end
|
|
18
|
-
@nationaldays
|
|
19
|
-
end
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
def holidays(year, month)
|
|
23
|
+
num_days_of_month = Date.new(year, month).end_of_month.day
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
1.upto(num_days_of_month) do |day|
|
|
26
|
+
wday = Date.new(year, month, day).wday
|
|
27
|
+
@holidays << "%04d-%02d-%02d" % [year, month, day] if wday == 6 || wday == 0
|
|
28
|
+
end
|
|
29
|
+
@holidays
|
|
27
30
|
end
|
|
28
|
-
@holidays
|
|
29
31
|
end
|
|
30
|
-
end
|
|
31
32
|
|
|
32
|
-
require 'holidays_in_month/version'
|
|
33
|
-
require 'active_support'
|
|
34
|
-
require 'active_support/time'
|
|
35
|
-
require 'time'
|
|
36
|
-
require 'yaml'
|
|
33
|
+
require 'holidays_in_month/version'
|
|
34
|
+
require 'active_support'
|
|
35
|
+
require 'active_support/time'
|
|
36
|
+
require 'time'
|
|
37
|
+
require 'yaml'
|