holidays 3.2.0 → 3.3.0
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/CHANGELOG.md +19 -0
- data/README.md +18 -9
- data/definitions/README.md +174 -0
- data/definitions/ar.yaml +37 -27
- data/definitions/au.yaml +73 -13
- data/definitions/{be.yaml → be_fr.yaml} +15 -15
- data/definitions/be_nl.yaml +65 -0
- data/definitions/cz.yaml +7 -4
- data/definitions/de.yaml +80 -10
- data/definitions/index.yaml +3 -2
- data/definitions/jp.yaml +20 -3
- data/definitions/nl.yaml +2 -1
- data/definitions/nz.yaml +0 -3
- data/lib/generated_definitions/MANIFEST +2 -0
- data/lib/generated_definitions/REGIONS.rb +1 -1
- data/lib/generated_definitions/ar.rb +9 -6
- data/lib/generated_definitions/au.rb +33 -9
- data/lib/generated_definitions/be_fr.rb +40 -0
- data/lib/generated_definitions/be_nl.rb +40 -0
- data/lib/generated_definitions/de.rb +14 -5
- data/lib/generated_definitions/europe.rb +37 -16
- data/lib/generated_definitions/jp.rb +3 -2
- data/lib/generated_definitions/nl.rb +1 -1
- data/lib/generated_definitions/nz.rb +0 -1
- data/lib/holidays.rb +12 -0
- data/lib/holidays/date_calculator/easter.rb +9 -9
- data/lib/holidays/date_calculator/weekend_modifier.rb +25 -4
- data/lib/holidays/definition/context/generator.rb +1 -1
- data/lib/holidays/definition/repository/holidays_by_month.rb +1 -1
- data/lib/holidays/option/context/parse_options.rb +1 -1
- data/lib/holidays/version.rb +1 -1
- data/test/defs/test_defs_ar.rb +18 -14
- data/test/defs/test_defs_au.rb +29 -2
- data/test/defs/{test_defs_be.rb → test_defs_be_fr.rb} +5 -4
- data/test/defs/test_defs_be_nl.rb +26 -0
- data/test/defs/test_defs_de.rb +25 -4
- data/test/defs/test_defs_europe.rb +44 -6
- data/test/defs/test_defs_jp.rb +8 -0
- data/test/holidays/date_calculator/test_weekend_modifier.rb +10 -0
- data/test/test_all_regions.rb +1 -1
- metadata +11 -6
- data/definitions/SYNTAX.rdoc +0 -111
@@ -75,7 +75,7 @@ module Holidays
|
|
75
75
|
|
76
76
|
exists = false
|
77
77
|
rules_by_month[month].each do |ex|
|
78
|
-
if ex[:name] == rule[:name] and ex[:wday] == rule[:wday] and ex[:mday] == rule[:mday] and ex[:week] == rule[:week] and ex[:type] == rule[:type] and ex[:function] == rule[:function] and ex[:observed] == rule[:observed]
|
78
|
+
if ex[:name] == rule[:name] and ex[:wday] == rule[:wday] and ex[:mday] == rule[:mday] and ex[:week] == rule[:week] and ex[:type] == rule[:type] and ex[:function] == rule[:function] and ex[:observed] == rule[:observed] and ex[:year_ranges] == rule[:year_ranges]
|
79
79
|
ex[:regions] << rule[:regions].flatten
|
80
80
|
exists = true
|
81
81
|
end
|
@@ -41,7 +41,7 @@ module Holidays
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def definition_exists?(existing_def, target_def)
|
44
|
-
existing_def[:name] == target_def[:name] && existing_def[:wday] == target_def[:wday] && existing_def[:mday] == target_def[:mday] && existing_def[:week] == target_def[:week] && existing_def[:function_id] == target_def[:function_id] && existing_def[:type] == target_def[:type] && existing_def[:observed_id] == target_def[:observed_id]
|
44
|
+
existing_def[:name] == target_def[:name] && existing_def[:wday] == target_def[:wday] && existing_def[:mday] == target_def[:mday] && existing_def[:week] == target_def[:week] && existing_def[:function_id] == target_def[:function_id] && existing_def[:type] == target_def[:type] && existing_def[:observed_id] == target_def[:observed_id] && existing_def[:year_ranges] == target_def[:year_ranges]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -56,7 +56,7 @@ module Holidays
|
|
56
56
|
region_definition = "#{DEFINITIONS_PATH}/#{region.to_s}"
|
57
57
|
begin
|
58
58
|
require region_definition #FIXME This is unacceptable, we can't be loading external files while parsing options
|
59
|
-
rescue LoadError
|
59
|
+
rescue LoadError
|
60
60
|
# This could be a sub region that does not have any holiday
|
61
61
|
# definitions of its own; try to load the containing region instead.
|
62
62
|
if region.to_s =~ /_/
|
data/lib/holidays/version.rb
CHANGED
data/test/defs/test_defs_ar.rb
CHANGED
@@ -7,21 +7,25 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
7
7
|
class ArDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_ar
|
10
|
-
{Date.civil(
|
11
|
-
Date.civil(
|
12
|
-
Date.civil(
|
13
|
-
Date.civil(
|
14
|
-
Date.civil(
|
15
|
-
Date.civil(
|
16
|
-
Date.civil(
|
17
|
-
Date.civil(
|
18
|
-
Date.civil(
|
19
|
-
Date.civil(
|
20
|
-
Date.civil(
|
21
|
-
Date.civil(
|
22
|
-
Date.civil(
|
23
|
-
Date.civil(
|
10
|
+
{Date.civil(2016,1,1) => 'Año Nuevo',
|
11
|
+
Date.civil(2016,2,8) => 'Carnaval',
|
12
|
+
Date.civil(2016,2,9) => 'Carnaval',
|
13
|
+
Date.civil(2016,3,24) => 'Día Nacional de la Memoria por la Verdad y la Justicia',
|
14
|
+
Date.civil(2016,3,25) => 'Viernes Santo',
|
15
|
+
Date.civil(2016,4,2) => 'Día del Veterano y de los Caídos en la Guerra de Malvinas',
|
16
|
+
Date.civil(2016,5,1) => 'Día del Trabajador',
|
17
|
+
Date.civil(2016,5,25) => 'Día de la Revolución de Mayo',
|
18
|
+
Date.civil(2016,6,20) => 'Día de la Bandera',
|
19
|
+
Date.civil(2016,7,8) => 'Feriado puente turístico',
|
20
|
+
Date.civil(2016,7,9) => 'Día de la Independencia',
|
21
|
+
Date.civil(2016,8,15) => 'Paso a la Inmortalidad del General José de San Martín',
|
22
|
+
Date.civil(2016,10,12) => 'Día del Respeto a la Diversidad Cultural',
|
23
|
+
Date.civil(2016,11,20) => 'Día de la Soberanía Nacional',
|
24
|
+
Date.civil(2016,12,8) => 'Inmaculada Concepción de María',
|
25
|
+
Date.civil(2016,12,9) => 'Feriado puente turístico',
|
26
|
+
Date.civil(2016,12,25) => 'Navidad'}.each do |date, name|
|
24
27
|
assert_equal name, (Holidays.on(date, :ar, :informal)[0] || {})[:name]
|
25
28
|
end
|
29
|
+
|
26
30
|
end
|
27
31
|
end
|
data/test/defs/test_defs_au.rb
CHANGED
@@ -11,8 +11,7 @@ class AuDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
11
11
|
Date.civil(2007,1,26) => 'Australia Day',
|
12
12
|
Date.civil(2007,4,6) => 'Good Friday',
|
13
13
|
Date.civil(2007,4,9) => 'Easter Monday',
|
14
|
-
Date.civil(2007,4,25) => 'ANZAC Day',
|
15
|
-
Date.civil(2007,12,25) => 'Christmas Day'}.each do |date, name|
|
14
|
+
Date.civil(2007,4,25) => 'ANZAC Day'}.each do |date, name|
|
16
15
|
assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name]
|
17
16
|
end
|
18
17
|
|
@@ -36,10 +35,14 @@ assert_equal 'Eight Hours Day', Holidays.on(Date.civil(2007,3,12), :au_tas)[0][:
|
|
36
35
|
|
37
36
|
assert_equal 'Labour Day', Holidays.on(Date.civil(2013,10,7), :au_qld)[0][:name]
|
38
37
|
assert_equal 'Labour Day', Holidays.on(Date.civil(2012,5,7), :au_qld)[0][:name]
|
38
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2015,10,5), :au_qld)[0][:name]
|
39
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2016,5,2), :au_qld)[0][:name]
|
39
40
|
|
40
41
|
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,6,11), :au_qld)[0][:name]
|
41
42
|
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,10,1), :au_qld)[0][:name]
|
42
43
|
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2013,6,10), :au_qld)[0][:name]
|
44
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015,6,8), :au_qld)[0][:name]
|
45
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2016,10,3), :au_qld)[0][:name]
|
43
46
|
|
44
47
|
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2014, 9, 29), :au_wa)[0][:name]
|
45
48
|
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015, 9, 28), :au_wa)[0][:name]
|
@@ -109,5 +112,29 @@ assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2014, 2, 10), :au_ta
|
|
109
112
|
assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2015, 2, 9), :au_tas_south)[0][:name]
|
110
113
|
assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2016, 2, 8), :au_tas_south)[0][:name]
|
111
114
|
|
115
|
+
# CHRISTMAS DAY - ACT, NSW, QLD, Tas, WA observe on 27th (and 25th) if 25th is a Sunday
|
116
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_qld)[0][:name]
|
117
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_qld, :observed)[0][:name]
|
118
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_nsw)[0][:name]
|
119
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_nsw, :observed)[0][:name]
|
120
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_act)[0][:name]
|
121
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_act, :observed)[0][:name]
|
122
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_tas)[0][:name]
|
123
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_tas, :observed)[0][:name]
|
124
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_wa)[0][:name]
|
125
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_wa, :observed)[0][:name]
|
126
|
+
|
127
|
+
# CHRISTMAS DAY - SA observes on 26th if 25th is a Sunday (Boxing Day goes to 27th)
|
128
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 25).holidays(:au_sa)[0][:name]
|
129
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 26).holidays(:au_sa, :observed)[0][:name]
|
130
|
+
assert_equal "Boxing Day", Date.civil(2016, 12, 27).holidays(:au_sa)[0][:name]
|
131
|
+
|
132
|
+
# CHRISTMAS DAY - Victoria and NT don't observe 25th if weekend - xmas is on the 27th
|
133
|
+
assert_nil Date.civil(2016, 12, 25).holidays(:au_vic)[0]
|
134
|
+
assert_nil Date.civil(2016, 12, 25).holidays(:au_nt)[0]
|
135
|
+
assert_equal "Boxing Day", Date.civil(2016, 12, 26).holidays(:au_vic)[0][:name]
|
136
|
+
assert_equal "Boxing Day", Date.civil(2016, 12, 26).holidays(:au_nt)[0][:name]
|
137
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_vic)[0][:name]
|
138
|
+
assert_equal "Christmas Day", Date.civil(2016, 12, 27).holidays(:au_nt)[0][:name]
|
112
139
|
end
|
113
140
|
end
|
@@ -3,10 +3,10 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded: definitions/
|
7
|
-
class
|
6
|
+
# Definitions loaded: definitions/be_fr.yaml
|
7
|
+
class Be_frDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_be_fr
|
10
10
|
{Date.civil(2007,1,1) => 'Jour de l\'an',
|
11
11
|
Date.civil(2007,4,8) => 'Pâques',
|
12
12
|
Date.civil(2007,4,9) => 'Lundi de Pâques',
|
@@ -19,7 +19,8 @@ class BeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
19
19
|
Date.civil(2007,11,1) => 'Toussaint',
|
20
20
|
Date.civil(2007,11,11) => 'Armistice 1918',
|
21
21
|
Date.civil(2007,12,25) => 'Noël'}.each do |date, name|
|
22
|
-
assert_equal name, (Holidays.on(date, :
|
22
|
+
assert_equal name, (Holidays.on(date, :be_fr, :informal)[0] || {})[:name]
|
23
23
|
end
|
24
|
+
|
24
25
|
end
|
25
26
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
3
|
+
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
5
|
+
#
|
6
|
+
# Definitions loaded: definitions/be_nl.yaml
|
7
|
+
class Be_nlDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
|
+
|
9
|
+
def test_be_nl
|
10
|
+
{Date.civil(2007,1,1) => 'Nieuwjaar',
|
11
|
+
Date.civil(2007,4,8) => 'Pasen',
|
12
|
+
Date.civil(2007,4,9) => 'Paasmaandag',
|
13
|
+
Date.civil(2007,5,1) => 'Feest van de Arbeid',
|
14
|
+
Date.civil(2007,5,17) => 'O.H. Hemelvaart',
|
15
|
+
Date.civil(2007,5,27) => 'Pinksteren',
|
16
|
+
Date.civil(2007,5,28) => 'Pinkstermaandag',
|
17
|
+
Date.civil(2007,7,21) => 'Nationale Feestdag',
|
18
|
+
Date.civil(2007,8,15) => 'O.L.V. Hemelvaart',
|
19
|
+
Date.civil(2007,11,1) => 'Allerheiligen',
|
20
|
+
Date.civil(2007,11,11) => 'Wapenstilstand 1918',
|
21
|
+
Date.civil(2007,12,25) => 'Kerstmis'}.each do |date, name|
|
22
|
+
assert_equal name, (Holidays.on(date, :be_nl, :informal)[0] || {})[:name]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/test/defs/test_defs_de.rb
CHANGED
@@ -7,16 +7,20 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
7
7
|
class DeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_de
|
10
|
-
{Date.civil(2009,1,1) => 'Neujahrstag',
|
10
|
+
{Date.civil(2009,1,1) => 'Neujahrstag',
|
11
11
|
Date.civil(2009,4,10) => 'Karfreitag',
|
12
|
+
Date.civil(2009,4,12) => 'Ostersonntag',
|
12
13
|
Date.civil(2009,4,13) => 'Ostermontag',
|
13
14
|
Date.civil(2009,5,1) => 'Tag der Arbeit',
|
14
15
|
Date.civil(2009,5,21) => 'Christi Himmelfahrt',
|
16
|
+
Date.civil(2009,5,31) => 'Pfingstsonntag',
|
15
17
|
Date.civil(2009,6,1) => 'Pfingstmontag',
|
16
18
|
Date.civil(2009,10,3) => 'Tag der Deutschen Einheit',
|
19
|
+
Date.civil(2009,12,24) => 'Heilig Abend',
|
17
20
|
Date.civil(2009,12,25) => '1. Weihnachtstag',
|
18
|
-
Date.civil(2009,12,26) => '2. Weihnachtstag'
|
19
|
-
|
21
|
+
Date.civil(2009,12,26) => '2. Weihnachtstag',
|
22
|
+
Date.civil(2009,12,31) => 'Silvester'}.each do |date, name|
|
23
|
+
assert_equal name, (Holidays.on(date, :de, :informal)[0] || {})[:name], "Failed on '#{name}' for date '#{date}'"
|
20
24
|
end
|
21
25
|
|
22
26
|
[:de_bw, :de_by, :de_st, :de_].each do |r|
|
@@ -35,12 +39,22 @@ end
|
|
35
39
|
assert_equal 'Reformationstag', Holidays.on(Date.civil(2009,10,31), r)[0][:name]
|
36
40
|
end
|
37
41
|
|
42
|
+
# Free day in schools
|
43
|
+
[:de_bw].each do |r|
|
44
|
+
assert_equal 'Reformationstag', Holidays.on(Date.civil(2009,10,31), r, :informal)[0][:name]
|
45
|
+
end
|
46
|
+
|
47
|
+
# 500 years reformation in 2017
|
48
|
+
assert_equal 'Reformationstag', Holidays.on(Date.civil(2017,10,31), :de)[0][:name]
|
49
|
+
assert_equal [], Holidays.on(Date.civil(2016,10,31), :de), "Reformationstag is not a holiday in 2016 in whole Germany"
|
50
|
+
assert_equal [], Holidays.on(Date.civil(2018,10,31), :de), "Reformationstag is not a holiday in 2018 in whole Germany"
|
51
|
+
|
38
52
|
[:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
39
53
|
assert_equal 'Allerheiligen', Holidays.on(Date.civil(2009,11,1), r)[0][:name]
|
40
54
|
end
|
41
55
|
|
42
56
|
[:de_by_aux].each do |r|
|
43
|
-
assert_equal 'Friedensfest', Date.civil(2015,8,8)
|
57
|
+
assert_equal 'Friedensfest', Holidays.on(Date.civil(2015,8,8),r)[0][:name]
|
44
58
|
end
|
45
59
|
|
46
60
|
[:de,
|
@@ -59,5 +73,12 @@ assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2005,11,16), :de_sn)[0][
|
|
59
73
|
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2006,11,22), :de_sn)[0][:name]
|
60
74
|
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2009,11,18), :de_sn)[0][:name]
|
61
75
|
|
76
|
+
# Carnival
|
77
|
+
[:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn].each do |r|
|
78
|
+
assert_equal 'Weiberfastnacht', Holidays.on(Date.civil(2016,2,4),r,:informal)[0][:name]
|
79
|
+
assert_equal 'Rosenmontag', Holidays.on(Date.civil(2016,2,8),r,:informal)[0][:name]
|
80
|
+
assert_equal 'Aschermittwoch', Holidays.on(Date.civil(2016,2,10),r,:informal)[0][:name]
|
81
|
+
end
|
82
|
+
|
62
83
|
end
|
63
84
|
end
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded: definitions/at.yaml, definitions/
|
6
|
+
# Definitions loaded: definitions/at.yaml, definitions/be_fr.yaml, definitions/be_nl.yaml, definitions/ch.yaml, definitions/cz.yaml, definitions/dk.yaml, definitions/de.yaml, definitions/el.yaml, definitions/es.yaml, definitions/fr.yaml, definitions/gb.yaml, definitions/hr.yaml, definitions/hu.yaml, definitions/ie.yaml, definitions/is.yaml, definitions/it.yaml, definitions/li.yaml, definitions/lt.yaml, definitions/nl.yaml, definitions/no.yaml, definitions/pl.yaml, definitions/pt.yaml, definitions/ro.yaml, definitions/sk.yaml, definitions/si.yaml, definitions/bg.yaml
|
7
7
|
class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_europe
|
@@ -33,9 +33,26 @@ assert_equal [], Holidays.on(Date.civil(2010,5,8), :at), '2010-05-08 is not a ho
|
|
33
33
|
Date.civil(2007,11,1) => 'Toussaint',
|
34
34
|
Date.civil(2007,11,11) => 'Armistice 1918',
|
35
35
|
Date.civil(2007,12,25) => 'Noël'}.each do |date, name|
|
36
|
-
assert_equal name, (Holidays.on(date, :
|
36
|
+
assert_equal name, (Holidays.on(date, :be_fr, :informal)[0] || {})[:name]
|
37
37
|
end
|
38
38
|
|
39
|
+
|
40
|
+
{Date.civil(2007,1,1) => 'Nieuwjaar',
|
41
|
+
Date.civil(2007,4,8) => 'Pasen',
|
42
|
+
Date.civil(2007,4,9) => 'Paasmaandag',
|
43
|
+
Date.civil(2007,5,1) => 'Feest van de Arbeid',
|
44
|
+
Date.civil(2007,5,17) => 'O.H. Hemelvaart',
|
45
|
+
Date.civil(2007,5,27) => 'Pinksteren',
|
46
|
+
Date.civil(2007,5,28) => 'Pinkstermaandag',
|
47
|
+
Date.civil(2007,7,21) => 'Nationale Feestdag',
|
48
|
+
Date.civil(2007,8,15) => 'O.L.V. Hemelvaart',
|
49
|
+
Date.civil(2007,11,1) => 'Allerheiligen',
|
50
|
+
Date.civil(2007,11,11) => 'Wapenstilstand 1918',
|
51
|
+
Date.civil(2007,12,25) => 'Kerstmis'}.each do |date, name|
|
52
|
+
assert_equal name, (Holidays.on(date, :be_nl, :informal)[0] || {})[:name]
|
53
|
+
end
|
54
|
+
|
55
|
+
|
39
56
|
{ Date.civil(2012,8,1) => 'Bundesfeiertag',
|
40
57
|
Date.civil(2012,12,25) => 'Weihnachten',
|
41
58
|
Date.civil(2012,05,17) => 'Auffahrt'
|
@@ -102,16 +119,20 @@ end
|
|
102
119
|
end
|
103
120
|
|
104
121
|
|
105
|
-
{Date.civil(2009,1,1) => 'Neujahrstag',
|
122
|
+
{Date.civil(2009,1,1) => 'Neujahrstag',
|
106
123
|
Date.civil(2009,4,10) => 'Karfreitag',
|
124
|
+
Date.civil(2009,4,12) => 'Ostersonntag',
|
107
125
|
Date.civil(2009,4,13) => 'Ostermontag',
|
108
126
|
Date.civil(2009,5,1) => 'Tag der Arbeit',
|
109
127
|
Date.civil(2009,5,21) => 'Christi Himmelfahrt',
|
128
|
+
Date.civil(2009,5,31) => 'Pfingstsonntag',
|
110
129
|
Date.civil(2009,6,1) => 'Pfingstmontag',
|
111
130
|
Date.civil(2009,10,3) => 'Tag der Deutschen Einheit',
|
131
|
+
Date.civil(2009,12,24) => 'Heilig Abend',
|
112
132
|
Date.civil(2009,12,25) => '1. Weihnachtstag',
|
113
|
-
Date.civil(2009,12,26) => '2. Weihnachtstag'
|
114
|
-
|
133
|
+
Date.civil(2009,12,26) => '2. Weihnachtstag',
|
134
|
+
Date.civil(2009,12,31) => 'Silvester'}.each do |date, name|
|
135
|
+
assert_equal name, (Holidays.on(date, :de, :informal)[0] || {})[:name], "Failed on '#{name}' for date '#{date}'"
|
115
136
|
end
|
116
137
|
|
117
138
|
[:de_bw, :de_by, :de_st, :de_].each do |r|
|
@@ -130,12 +151,22 @@ end
|
|
130
151
|
assert_equal 'Reformationstag', Holidays.on(Date.civil(2009,10,31), r)[0][:name]
|
131
152
|
end
|
132
153
|
|
154
|
+
# Free day in schools
|
155
|
+
[:de_bw].each do |r|
|
156
|
+
assert_equal 'Reformationstag', Holidays.on(Date.civil(2009,10,31), r, :informal)[0][:name]
|
157
|
+
end
|
158
|
+
|
159
|
+
# 500 years reformation in 2017
|
160
|
+
assert_equal 'Reformationstag', Holidays.on(Date.civil(2017,10,31), :de)[0][:name]
|
161
|
+
assert_equal [], Holidays.on(Date.civil(2016,10,31), :de), "Reformationstag is not a holiday in 2016 in whole Germany"
|
162
|
+
assert_equal [], Holidays.on(Date.civil(2018,10,31), :de), "Reformationstag is not a holiday in 2018 in whole Germany"
|
163
|
+
|
133
164
|
[:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
134
165
|
assert_equal 'Allerheiligen', Holidays.on(Date.civil(2009,11,1), r)[0][:name]
|
135
166
|
end
|
136
167
|
|
137
168
|
[:de_by_aux].each do |r|
|
138
|
-
assert_equal 'Friedensfest', Date.civil(2015,8,8)
|
169
|
+
assert_equal 'Friedensfest', Holidays.on(Date.civil(2015,8,8),r)[0][:name]
|
139
170
|
end
|
140
171
|
|
141
172
|
[:de,
|
@@ -154,6 +185,13 @@ assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2005,11,16), :de_sn)[0][
|
|
154
185
|
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2006,11,22), :de_sn)[0][:name]
|
155
186
|
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2009,11,18), :de_sn)[0][:name]
|
156
187
|
|
188
|
+
# Carnival
|
189
|
+
[:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn].each do |r|
|
190
|
+
assert_equal 'Weiberfastnacht', Holidays.on(Date.civil(2016,2,4),r,:informal)[0][:name]
|
191
|
+
assert_equal 'Rosenmontag', Holidays.on(Date.civil(2016,2,8),r,:informal)[0][:name]
|
192
|
+
assert_equal 'Aschermittwoch', Holidays.on(Date.civil(2016,2,10),r,:informal)[0][:name]
|
193
|
+
end
|
194
|
+
|
157
195
|
|
158
196
|
{Date.civil(2011,1,1) => 'Πρωτοχρονιά',
|
159
197
|
Date.civil(2011,1,6) => 'Θεοφάνεια',
|
data/test/defs/test_defs_jp.rb
CHANGED
@@ -51,6 +51,14 @@ end
|
|
51
51
|
assert_equal '国民の休日', Holidays.on(date, :jp)[0][:name]
|
52
52
|
end
|
53
53
|
|
54
|
+
# marine day since 1996
|
55
|
+
[Date.civil(1996, 7, 20), Date.civil(2002, 7, 20), Date.civil(2003, 7, 21),
|
56
|
+
Date.civil(2004, 7, 19), Date.civil(2005, 7, 18), Date.civil(2006, 7, 17),
|
57
|
+
Date.civil(2007, 7, 16), Date.civil(2009, 7, 20), Date.civil(2013, 7, 15),
|
58
|
+
Date.civil(2014, 7, 21)].each do |date|
|
59
|
+
assert_equal '海の日', Holidays.on(date, :jp)[0][:name]
|
60
|
+
end
|
61
|
+
|
54
62
|
# mountain holiday start since 2016
|
55
63
|
[Date.civil(2016,8,11), Date.civil(2017,8,11),Date.civil(2018,8,11),
|
56
64
|
Date.civil(2019,8,11), Date.civil(2020,8,11),Date.civil(2021,8,11),
|
@@ -30,4 +30,14 @@ class WeekendModifierDateCalculatorTests < Test::Unit::TestCase
|
|
30
30
|
def test_to_weekday_if_boxing_weekend_from_year
|
31
31
|
assert_equal Date.civil(2015, 12, 28), @subject.to_weekday_if_boxing_weekend_from_year(2015)
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday
|
35
|
+
assert_equal Date.civil(2015, 12, 28), @subject.to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(2015) # saturday to monday
|
36
|
+
assert_equal Date.civil(2016, 12, 27), @subject.to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(2016) # monday to tuesday
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_to_tuesday_if_sunday_or_monday_if_saturday
|
40
|
+
assert_equal Date.civil(2016, 12, 26), @subject.to_tuesday_if_sunday_or_monday_if_saturday(Date.civil(2016, 12, 24)) # sat to mon
|
41
|
+
assert_equal Date.civil(2016, 12, 27), @subject.to_tuesday_if_sunday_or_monday_if_saturday(Date.civil(2016, 12, 25)) # sun to tue
|
42
|
+
end
|
33
43
|
end
|
data/test/test_all_regions.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holidays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dunae
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -98,11 +98,12 @@ files:
|
|
98
98
|
- Rakefile
|
99
99
|
- bin/console
|
100
100
|
- bin/setup
|
101
|
-
- definitions/
|
101
|
+
- definitions/README.md
|
102
102
|
- definitions/ar.yaml
|
103
103
|
- definitions/at.yaml
|
104
104
|
- definitions/au.yaml
|
105
|
-
- definitions/
|
105
|
+
- definitions/be_fr.yaml
|
106
|
+
- definitions/be_nl.yaml
|
106
107
|
- definitions/bg.yaml
|
107
108
|
- definitions/br.yaml
|
108
109
|
- definitions/ca.yaml
|
@@ -158,6 +159,8 @@ files:
|
|
158
159
|
- lib/generated_definitions/at.rb
|
159
160
|
- lib/generated_definitions/au.rb
|
160
161
|
- lib/generated_definitions/be.rb
|
162
|
+
- lib/generated_definitions/be_fr.rb
|
163
|
+
- lib/generated_definitions/be_nl.rb
|
161
164
|
- lib/generated_definitions/bg.rb
|
162
165
|
- lib/generated_definitions/br.rb
|
163
166
|
- lib/generated_definitions/ca.rb
|
@@ -234,7 +237,8 @@ files:
|
|
234
237
|
- test/defs/test_defs_ar.rb
|
235
238
|
- test/defs/test_defs_at.rb
|
236
239
|
- test/defs/test_defs_au.rb
|
237
|
-
- test/defs/
|
240
|
+
- test/defs/test_defs_be_fr.rb
|
241
|
+
- test/defs/test_defs_be_nl.rb
|
238
242
|
- test/defs/test_defs_bg.rb
|
239
243
|
- test/defs/test_defs_br.rb
|
240
244
|
- test/defs/test_defs_ca.rb
|
@@ -343,7 +347,8 @@ test_files:
|
|
343
347
|
- test/defs/test_defs_ar.rb
|
344
348
|
- test/defs/test_defs_at.rb
|
345
349
|
- test/defs/test_defs_au.rb
|
346
|
-
- test/defs/
|
350
|
+
- test/defs/test_defs_be_fr.rb
|
351
|
+
- test/defs/test_defs_be_nl.rb
|
347
352
|
- test/defs/test_defs_bg.rb
|
348
353
|
- test/defs/test_defs_br.rb
|
349
354
|
- test/defs/test_defs_ca.rb
|
data/definitions/SYNTAX.rdoc
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
== Holiday Gem Definition Syntax
|
2
|
-
|
3
|
-
All holidays are defined in YAML files in the <tt>data/</tt> directory. These definition files have three main parts: *months*, *methods* and *tests*. Before you start, you may want to look some of the existing files at http://code.dunae.ca/svn/holidays/trunk/data.
|
4
|
-
|
5
|
-
=== Months
|
6
|
-
|
7
|
-
Holidays are grouped by month from 1 through 12. Each entry within a month can have several fields.
|
8
|
-
|
9
|
-
[<tt>name</tt>] The name of the holiday.
|
10
|
-
[<tt>regions</tt>] One or more region codes.
|
11
|
-
|
12
|
-
===== Dates defined by a fixed date (e.g. January 1st)
|
13
|
-
|
14
|
-
[<tt>mday</tt>] Integer representing day of the month (1 through 31).
|
15
|
-
|
16
|
-
For example, the following holiday is on the first of January and available in the <tt>ca</tt>, <tt>us</tt> and <tt>au</tt> regions.
|
17
|
-
|
18
|
-
1:
|
19
|
-
- name: New Year's Day
|
20
|
-
regions: [ca, us, au]
|
21
|
-
mday: 1
|
22
|
-
|
23
|
-
===== Dates defined by a week number (e.g. first Monday of a month)
|
24
|
-
|
25
|
-
[<tt>wday</tt>] Integer representing day of the week (0 = Sunday through 6 = Saturday).
|
26
|
-
[<tt>week</tt>] Integer representing week number (1 = first week, 3 = third week, -1 = last week),
|
27
|
-
|
28
|
-
|
29
|
-
For example, the following holiday is on the first Monday of September and available in the <tt>ca</tt> region.
|
30
|
-
|
31
|
-
9:
|
32
|
-
- name: Labour Day
|
33
|
-
regions: [ca]
|
34
|
-
week: 1
|
35
|
-
wday: 1
|
36
|
-
|
37
|
-
=== Calculating dates with methods
|
38
|
-
|
39
|
-
In addition to defining holidays by day or week, you can create custom methods to calculate a date.
|
40
|
-
|
41
|
-
For example, Canada celebrates Victoria Day, which falls on the Monday on or before May 24. So, under the <tt>methods</tt> section we could create a custom method that returns a Date object.
|
42
|
-
|
43
|
-
methods:
|
44
|
-
ca_victoria_day: |
|
45
|
-
def self.ca_victoria_day(year)
|
46
|
-
date = Date.civil(year,5,24)
|
47
|
-
if date.wday > 1
|
48
|
-
date -= (date.wday - 1)
|
49
|
-
elsif date.wday == 0
|
50
|
-
date -= 6
|
51
|
-
end
|
52
|
-
date
|
53
|
-
end
|
54
|
-
|
55
|
-
This would be represented in the <tt>months</tt> section as:
|
56
|
-
|
57
|
-
5:
|
58
|
-
- name: Victoria Day
|
59
|
-
regions: [ca]
|
60
|
-
function: ca_victoria_day(year)
|
61
|
-
|
62
|
-
If a holiday can occur in different months (e.g. Easter) it can go in the '0' month.
|
63
|
-
|
64
|
-
0:
|
65
|
-
- name: Easter Monday
|
66
|
-
regions: [ca]
|
67
|
-
function: easter(year)+1
|
68
|
-
|
69
|
-
Calculated-date functions take the year (integer) as a parameter and must return either a Date object or an integer representing the day of the month.
|
70
|
-
|
71
|
-
|
72
|
-
=== Calculating observed dates
|
73
|
-
|
74
|
-
Several built-in methods are available for holidays that are observed on varying dates. For example, for a holiday that is observed on Monday if it falls on a weekend you could write:
|
75
|
-
|
76
|
-
7:
|
77
|
-
- name: Canada Day
|
78
|
-
regions: [ca]
|
79
|
-
mday: 1
|
80
|
-
observed: to_monday_if_weekend(date)
|
81
|
-
|
82
|
-
Methods included in the Holidays module are:
|
83
|
-
|
84
|
-
* Holidays#to_monday_if_sunday
|
85
|
-
* Holidays#to_monday_if_weekend
|
86
|
-
* Holidays#to_weekday_if_boxing_weekend
|
87
|
-
* Holidays#to_weekday_if_weekend
|
88
|
-
|
89
|
-
Observed-date functions take a Date object as a parameter and must return either a Date object or an integer representing the day of the month.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
=== Tests
|
94
|
-
|
95
|
-
All definition files should have tests included. In the YAML file, tests are just a block of Ruby code.
|
96
|
-
|
97
|
-
tests: |
|
98
|
-
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
99
|
-
Date.civil(2008,3,21) => 'Good Friday',
|
100
|
-
Date.civil(2008,3,24) => 'Easter Monday',
|
101
|
-
Date.civil(2008,9,1) => 'Labour Day',
|
102
|
-
Date.civil(2008,12,25) => 'Christmas Day',
|
103
|
-
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
|
104
|
-
assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name]
|
105
|
-
end
|
106
|
-
|
107
|
-
# Victoria Day
|
108
|
-
[Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
|
109
|
-
Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
|
110
|
-
assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
|
111
|
-
end
|