alexdunae-holidays 0.9.4
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.
- data/CHANGELOG +15 -0
- data/LICENSE +21 -0
- data/README.rdoc +77 -0
- data/REFERENCES +16 -0
- data/data/SYNTAX +111 -0
- data/data/au.yaml +106 -0
- data/data/build_defs.rb +152 -0
- data/data/ca.yaml +141 -0
- data/data/de.yaml +115 -0
- data/data/dk.yaml +117 -0
- data/data/es.yaml +161 -0
- data/data/fr.yaml +70 -0
- data/data/gb.yaml +106 -0
- data/data/ie.yaml +58 -0
- data/data/index.yaml +23 -0
- data/data/is.yaml +136 -0
- data/data/it.yaml +66 -0
- data/data/mx.yaml +106 -0
- data/data/nl.yaml +67 -0
- data/data/north_america_informal.yaml +49 -0
- data/data/nyse.yaml +63 -0
- data/data/pt.yaml +85 -0
- data/data/se.yaml +91 -0
- data/data/united_nations.yaml +188 -0
- data/data/ups.yaml +56 -0
- data/data/us.yaml +81 -0
- data/data/za.yaml +78 -0
- data/lib/holidays.rb +404 -0
- data/lib/holidays/MANIFEST +25 -0
- data/lib/holidays/au.rb +41 -0
- data/lib/holidays/ca.rb +68 -0
- data/lib/holidays/de.rb +52 -0
- data/lib/holidays/dk.rb +47 -0
- data/lib/holidays/es.rb +52 -0
- data/lib/holidays/europe.rb +215 -0
- data/lib/holidays/fr.rb +36 -0
- data/lib/holidays/gb.rb +40 -0
- data/lib/holidays/ie.rb +32 -0
- data/lib/holidays/is.rb +61 -0
- data/lib/holidays/it.rb +35 -0
- data/lib/holidays/mx.rb +51 -0
- data/lib/holidays/nl.rb +36 -0
- data/lib/holidays/north_america.rb +107 -0
- data/lib/holidays/nyse.rb +32 -0
- data/lib/holidays/pt.rb +37 -0
- data/lib/holidays/scandinavia.rb +114 -0
- data/lib/holidays/se.rb +52 -0
- data/lib/holidays/united_nations.rb +24 -0
- data/lib/holidays/ups.rb +31 -0
- data/lib/holidays/us.rb +48 -0
- data/lib/holidays/za.rb +35 -0
- data/test/defs/test_defs_au.rb +36 -0
- data/test/defs/test_defs_ca.rb +29 -0
- data/test/defs/test_defs_de.rb +46 -0
- data/test/defs/test_defs_dk.rb +30 -0
- data/test/defs/test_defs_es.rb +57 -0
- data/test/defs/test_defs_europe.rb +240 -0
- data/test/defs/test_defs_fr.rb +26 -0
- data/test/defs/test_defs_gb.rb +36 -0
- data/test/defs/test_defs_ie.rb +21 -0
- data/test/defs/test_defs_is.rb +33 -0
- data/test/defs/test_defs_it.rb +25 -0
- data/test/defs/test_defs_mx.rb +22 -0
- data/test/defs/test_defs_nl.rb +24 -0
- data/test/defs/test_defs_north_america.rb +54 -0
- data/test/defs/test_defs_nyse.rb +22 -0
- data/test/defs/test_defs_pt.rb +32 -0
- data/test/defs/test_defs_scandinavia.rb +75 -0
- data/test/defs/test_defs_se.rb +32 -0
- data/test/defs/test_defs_ups.rb +21 -0
- data/test/defs/test_defs_us.rb +23 -0
- data/test/defs/test_defs_za.rb +25 -0
- data/test/test_date.rb +87 -0
- data/test/test_helper.rb +11 -0
- data/test/test_holidays.rb +117 -0
- data/test/test_multiple_regions.rb +20 -0
- metadata +164 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/mx'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/mx.yaml, data/north_america_informal.yaml
|
|
7
|
+
class MxDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_mx
|
|
10
|
+
{Date.civil(2007,1,1) => 'Año nuevo',
|
|
11
|
+
Date.civil(2007,2,5) => 'Día de la Constitución',
|
|
12
|
+
Date.civil(2007,5,1) => 'Día del Trabajo',
|
|
13
|
+
Date.civil(2007,5,5) => 'Cinco de Mayo',
|
|
14
|
+
Date.civil(2007,9,16) => 'Día de la Independencia',
|
|
15
|
+
Date.civil(2007,11,1) => 'Todos los Santos',
|
|
16
|
+
Date.civil(2007,11,2) => 'Los Fieles Difuntos',
|
|
17
|
+
Date.civil(2007,11,19) => 'Día de la Revolución',
|
|
18
|
+
Date.civil(2007,12,25) => 'Navidad'}.each do |date, name|
|
|
19
|
+
assert_equal name, Holidays.on(date, :mx, :informal)[0][:name]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/nl'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/nl.yaml
|
|
7
|
+
class NlDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_nl
|
|
10
|
+
{Date.civil(2008,1,1) => 'Nieuwjaar',
|
|
11
|
+
Date.civil(2008,3,21) => 'Goede Vrijdag',
|
|
12
|
+
Date.civil(2008,3,23) => 'Pasen',
|
|
13
|
+
Date.civil(2008,3,24) => 'Pasen',
|
|
14
|
+
Date.civil(2008,4,30) => 'Koninginnedag',
|
|
15
|
+
Date.civil(2008,5,1) => 'Hemelvaartsdag', # Ascension, Easter+39
|
|
16
|
+
Date.civil(2008,5,5) => 'Bevrijdingsdag',
|
|
17
|
+
Date.civil(2008,5,11) => 'Pinksteren', # Pentecost, Easter+49
|
|
18
|
+
Date.civil(2008,5,12) => 'Pinksteren', # Pentecost, Easter+50
|
|
19
|
+
Date.civil(2008,12,25) => 'Kerstmis',
|
|
20
|
+
Date.civil(2008,12,26) => 'Kerstmis'}.each do |date, name|
|
|
21
|
+
assert_equal name, Holidays.on(date, :nl, :informal)[0][:name]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/north_america'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/north_america_informal.yaml
|
|
7
|
+
class North_americaDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_north_america
|
|
10
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
11
|
+
Date.civil(2008,3,21) => 'Good Friday',
|
|
12
|
+
Date.civil(2008,3,24) => 'Easter Monday',
|
|
13
|
+
Date.civil(2008,5,19) => 'Victoria Day',
|
|
14
|
+
Date.civil(2008,7,1) => 'Canada Day',
|
|
15
|
+
Date.civil(2008,9,1) => 'Labour Day',
|
|
16
|
+
Date.civil(2008,10,13) => 'Thanksgiving',
|
|
17
|
+
Date.civil(2008,11,11) => 'Rememberance Day',
|
|
18
|
+
Date.civil(2008,12,25) => 'Christmas Day',
|
|
19
|
+
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
|
|
20
|
+
assert_equal name, Holidays.on(date, :ca, :informal)[0][:name]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Victoria Day
|
|
24
|
+
[Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
|
|
25
|
+
Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
|
|
26
|
+
assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
{Date.civil(2007,1,1) => 'Año nuevo',
|
|
30
|
+
Date.civil(2007,2,5) => 'Día de la Constitución',
|
|
31
|
+
Date.civil(2007,5,1) => 'Día del Trabajo',
|
|
32
|
+
Date.civil(2007,5,5) => 'Cinco de Mayo',
|
|
33
|
+
Date.civil(2007,9,16) => 'Día de la Independencia',
|
|
34
|
+
Date.civil(2007,11,1) => 'Todos los Santos',
|
|
35
|
+
Date.civil(2007,11,2) => 'Los Fieles Difuntos',
|
|
36
|
+
Date.civil(2007,11,19) => 'Día de la Revolución',
|
|
37
|
+
Date.civil(2007,12,25) => 'Navidad'}.each do |date, name|
|
|
38
|
+
assert_equal name, Holidays.on(date, :mx, :informal)[0][:name]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
42
|
+
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
|
43
|
+
Date.civil(2008,2,18) => 'Presidents\' Day',
|
|
44
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
|
45
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
|
46
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
|
47
|
+
Date.civil(2008,10,13) => 'Columbus Day',
|
|
48
|
+
Date.civil(2008,11,11) => 'Veterans Day',
|
|
49
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
|
50
|
+
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
|
51
|
+
assert_equal name, Holidays.on(date, :us)[0][:name]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/nyse'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/nyse.yaml
|
|
7
|
+
class NyseDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_nyse
|
|
10
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
11
|
+
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
|
12
|
+
Date.civil(2008,2,18) => 'Presidents\' Day',
|
|
13
|
+
Date.civil(2008,3,21) => 'Good Friday',
|
|
14
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
|
15
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
|
16
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
|
17
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
|
18
|
+
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
|
19
|
+
assert_equal name, Holidays.on(date, :nyse)[0][:name]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/pt'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/pt.yaml
|
|
7
|
+
class PtDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_pt
|
|
10
|
+
{Date.civil(2008,1,1) => 'Ano Novo',
|
|
11
|
+
Date.civil(2005,2,8) => 'Carnaval',
|
|
12
|
+
Date.civil(2006,2,28) => 'Carnaval',
|
|
13
|
+
Date.civil(2007,2,20) => 'Carnaval',
|
|
14
|
+
Date.civil(2008,2,5) => 'Carnaval',
|
|
15
|
+
Date.civil(2008,3,21) => 'Sexta-feira Santa',
|
|
16
|
+
Date.civil(2008,3,23) => 'Páscoa',
|
|
17
|
+
Date.civil(2008,4,25) => 'Dia da Liberdade',
|
|
18
|
+
Date.civil(2008,5,1) => 'Dia do Trabalhador',
|
|
19
|
+
Date.civil(2005,5,26) => 'Corpo de Deus',
|
|
20
|
+
Date.civil(2007,6,7) => 'Corpo de Deus',
|
|
21
|
+
Date.civil(2008,5,22) => 'Corpo de Deus',
|
|
22
|
+
Date.civil(2008,6,10) => 'Dia de Portugal',
|
|
23
|
+
Date.civil(2008,8,15) => 'Assunção de Nossa Senhora',
|
|
24
|
+
Date.civil(2008,10,5) => 'Implantação da República',
|
|
25
|
+
Date.civil(2008,11,1) => 'Todos os Santos',
|
|
26
|
+
Date.civil(2008,12,1) => 'Restauração da Independência',
|
|
27
|
+
Date.civil(2008,12,8) => 'Imaculada Conceição',
|
|
28
|
+
Date.civil(2008,12,25) => 'Natal'}.each do |date, name|
|
|
29
|
+
assert_equal name, Holidays.on(date, :pt, :informal)[0][:name]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/scandinavia'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/dk.yaml, data/is.yaml, data/se.yaml
|
|
7
|
+
class ScandinaviaDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_scandinavia
|
|
10
|
+
{Date.civil(2007,1,1) => 'Nytårsdag',
|
|
11
|
+
Date.civil(2007,2,18) => 'Fastelavn',
|
|
12
|
+
Date.civil(2007,4,9) => 'Danmarks besættelse',
|
|
13
|
+
Date.civil(2007,4,16) => 'Dronningens fødselsdag',
|
|
14
|
+
Date.civil(2007,4,5) => 'Skærtorsdag',
|
|
15
|
+
Date.civil(2007,4,6) => 'Langfredag',
|
|
16
|
+
Date.civil(2007,4,8) => 'Påskedag',
|
|
17
|
+
Date.civil(2007,4,9) => '2. påskedag',
|
|
18
|
+
Date.civil(2007,5,1) => 'Arbejdernes kampdag',
|
|
19
|
+
Date.civil(2007,5,4) => 'Store Bededag',
|
|
20
|
+
Date.civil(2007,5,17) => 'Kristi Himmelfartsdag',
|
|
21
|
+
Date.civil(2007,5,27) => 'Pinsedag',
|
|
22
|
+
Date.civil(2007,5,28) => '2. Pinsedag',
|
|
23
|
+
Date.civil(2007,6,5) => 'Grundlovsdag',
|
|
24
|
+
Date.civil(2007,12,24) => 'Juleaftensdag',
|
|
25
|
+
Date.civil(2007,12,25) => '1. juledag',
|
|
26
|
+
Date.civil(2007,12,26) => '2. juledag'}.each do |date, name|
|
|
27
|
+
assert_equal name, Holidays.on(date, :dk, :informal)[0][:name]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
{Date.civil(2007,1,1) => 'Nýársdagur',
|
|
31
|
+
Date.civil(2007,1,6) => 'Þrettándinn',
|
|
32
|
+
Date.civil(2007,1,19) => 'Bóndadagur',
|
|
33
|
+
Date.civil(2007,2,18) => 'Konudagur',
|
|
34
|
+
Date.civil(2007,4,5) => 'Skírdagur',
|
|
35
|
+
Date.civil(2007,4,6) => 'Föstudaginn langi',
|
|
36
|
+
Date.civil(2007,4,8) => 'Páskadagur',
|
|
37
|
+
Date.civil(2007,4,9) => 'Annar í páskum',
|
|
38
|
+
Date.civil(2007,4,19) => 'Sumardagurinn fyrsti',
|
|
39
|
+
Date.civil(2007,5,1) => 'Verkalýðsdagurinn',
|
|
40
|
+
Date.civil(2007,5,17) => 'Uppstigningardagur',
|
|
41
|
+
Date.civil(2007,5,27) => 'Hvítasunnudagur',
|
|
42
|
+
Date.civil(2007,5,28) => 'Annar í hvítasunnu',
|
|
43
|
+
Date.civil(2007,6,3) => 'Sjómannadagurinn',
|
|
44
|
+
Date.civil(2007,6,17) => 'Lýðveldisdagurinn',
|
|
45
|
+
Date.civil(2007,8,6) => 'Frídagur verslunarmanna',
|
|
46
|
+
Date.civil(2007,12,24) => 'Jól',
|
|
47
|
+
Date.civil(2007,12,25) => 'Jól',
|
|
48
|
+
Date.civil(2007,12,26) => 'Jól',
|
|
49
|
+
Date.civil(2007,12,31) => 'Gamlárskvöld'}.each do |date, name|
|
|
50
|
+
assert_equal name, Holidays.on(date, :is, :informal)[0][:name]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
{Date.civil(2008,1,1) => 'Nyårsdagen',
|
|
54
|
+
Date.civil(2008,1,6) => 'Trettondedag jul',
|
|
55
|
+
Date.civil(2008,3,21) => 'Långfredagen',
|
|
56
|
+
Date.civil(2008,3,23) => 'Påskdagen',
|
|
57
|
+
Date.civil(2008,3,24) => 'Annandag påsk',
|
|
58
|
+
Date.civil(2008,5,1) => 'Första maj',
|
|
59
|
+
Date.civil(2008,5,1) => 'Kristi himmelsfärdsdag',
|
|
60
|
+
Date.civil(2008,5,11) => 'Pingstdagen',
|
|
61
|
+
Date.civil(2008,6,6) => 'Nationaldagen',
|
|
62
|
+
Date.civil(2005,6,25) => 'Midsommardagen',
|
|
63
|
+
Date.civil(2006,6,24) => 'Midsommardagen',
|
|
64
|
+
Date.civil(2007,6,23) => 'Midsommardagen',
|
|
65
|
+
Date.civil(2008,6,21) => 'Midsommardagen',
|
|
66
|
+
Date.civil(2005,11,5) => 'Alla helgons dag',
|
|
67
|
+
Date.civil(2006,11,4) => 'Alla helgons dag',
|
|
68
|
+
Date.civil(2007,11,3) => 'Alla helgons dag',
|
|
69
|
+
Date.civil(2008,11,1) => 'Alla helgons dag',
|
|
70
|
+
Date.civil(2008,12,25) => 'Juldagen',
|
|
71
|
+
Date.civil(2008,12,26) => 'Annandag jul'}.each do |date, name|
|
|
72
|
+
assert_equal name, Holidays.on(date, :se, :informal)[0][:name]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/se'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/se.yaml
|
|
7
|
+
class SeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_se
|
|
10
|
+
{Date.civil(2008,1,1) => 'Nyårsdagen',
|
|
11
|
+
Date.civil(2008,1,6) => 'Trettondedag jul',
|
|
12
|
+
Date.civil(2008,3,21) => 'Långfredagen',
|
|
13
|
+
Date.civil(2008,3,23) => 'Påskdagen',
|
|
14
|
+
Date.civil(2008,3,24) => 'Annandag påsk',
|
|
15
|
+
Date.civil(2008,5,1) => 'Första maj',
|
|
16
|
+
Date.civil(2008,5,1) => 'Kristi himmelsfärdsdag',
|
|
17
|
+
Date.civil(2008,5,11) => 'Pingstdagen',
|
|
18
|
+
Date.civil(2008,6,6) => 'Nationaldagen',
|
|
19
|
+
Date.civil(2005,6,25) => 'Midsommardagen',
|
|
20
|
+
Date.civil(2006,6,24) => 'Midsommardagen',
|
|
21
|
+
Date.civil(2007,6,23) => 'Midsommardagen',
|
|
22
|
+
Date.civil(2008,6,21) => 'Midsommardagen',
|
|
23
|
+
Date.civil(2005,11,5) => 'Alla helgons dag',
|
|
24
|
+
Date.civil(2006,11,4) => 'Alla helgons dag',
|
|
25
|
+
Date.civil(2007,11,3) => 'Alla helgons dag',
|
|
26
|
+
Date.civil(2008,11,1) => 'Alla helgons dag',
|
|
27
|
+
Date.civil(2008,12,25) => 'Juldagen',
|
|
28
|
+
Date.civil(2008,12,26) => 'Annandag jul'}.each do |date, name|
|
|
29
|
+
assert_equal name, Holidays.on(date, :se, :informal)[0][:name]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/ups'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/ups.yaml
|
|
7
|
+
class UpsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_ups
|
|
10
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
11
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
|
12
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
|
13
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
|
14
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
|
15
|
+
Date.civil(2008,11,28) => 'Day After Thanksgiving',
|
|
16
|
+
Date.civil(2008,12,25) => 'Christmas Day',
|
|
17
|
+
Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
|
|
18
|
+
assert_equal name, Holidays.on(date, :ups)[0][:name]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/us'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/us.yaml, data/north_america_informal.yaml
|
|
7
|
+
class UsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_us
|
|
10
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
11
|
+
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
|
12
|
+
Date.civil(2008,2,18) => 'Presidents\' Day',
|
|
13
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
|
14
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
|
15
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
|
16
|
+
Date.civil(2008,10,13) => 'Columbus Day',
|
|
17
|
+
Date.civil(2008,11,11) => 'Veterans Day',
|
|
18
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
|
19
|
+
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
|
20
|
+
assert_equal name, Holidays.on(date, :us)[0][:name]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
require 'holidays/za'
|
|
3
|
+
|
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
|
5
|
+
#
|
|
6
|
+
# Definitions loaded: data/za.yaml
|
|
7
|
+
class ZaDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
8
|
+
|
|
9
|
+
def test_za
|
|
10
|
+
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
|
11
|
+
Date.civil(2007,3,21) => 'Human Rights Day',
|
|
12
|
+
Date.civil(2007,4,6) => 'Good Friday',
|
|
13
|
+
Date.civil(2007,4,9) => 'Family Day',
|
|
14
|
+
Date.civil(2007,4,27) => 'Freedom Day',
|
|
15
|
+
Date.civil(2007,5,1) => 'Workers Day',
|
|
16
|
+
Date.civil(2007,6,16) => 'Youth Day',
|
|
17
|
+
Date.civil(2007,8,9) => 'National Women\'s Day',
|
|
18
|
+
Date.civil(2007,9,24) => 'Heritage Day',
|
|
19
|
+
Date.civil(2007,12,16) => 'Day of Reconciliation',
|
|
20
|
+
Date.civil(2007,12,25) => 'Christmas Day',
|
|
21
|
+
Date.civil(2007,12,26) => 'Day of Goodwill'}.each do |date, name|
|
|
22
|
+
assert_equal name, Holidays.on(date, :za, :informal)[0][:name]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/test/test_date.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
class DateTests < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@date = Date.civil(2008,1,1)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_extending_date_class
|
|
9
|
+
assert @date.respond_to?('holiday?')
|
|
10
|
+
assert @date.respond_to?('holiday?')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_calculating_mdays
|
|
14
|
+
# US Memorial day
|
|
15
|
+
assert_equal 29, Date.calculate_mday(2006, 5, :last, 1)
|
|
16
|
+
assert_equal 28, Date.calculate_mday(2007, 5, :last, 1)
|
|
17
|
+
assert_equal 26, Date.calculate_mday(2008, 5, :last, 1)
|
|
18
|
+
assert_equal 25, Date.calculate_mday(2009, 5, :last, 1)
|
|
19
|
+
assert_equal 31, Date.calculate_mday(2010, 5, :last, 1)
|
|
20
|
+
assert_equal 30, Date.calculate_mday(2011, 5, :last, 1)
|
|
21
|
+
|
|
22
|
+
# Labour day
|
|
23
|
+
assert_equal 3, Date.calculate_mday(2007, 9, :first, 1)
|
|
24
|
+
assert_equal 1, Date.calculate_mday(2008, 9, :first, :monday)
|
|
25
|
+
assert_equal 7, Date.calculate_mday(2009, 9, :first, 1)
|
|
26
|
+
assert_equal 5, Date.calculate_mday(2011, 9, :first, 1)
|
|
27
|
+
assert_equal 5, Date.calculate_mday(2050, 9, :first, 1)
|
|
28
|
+
assert_equal 4, Date.calculate_mday(2051, 9, :first, 1)
|
|
29
|
+
|
|
30
|
+
# Canadian thanksgiving
|
|
31
|
+
assert_equal 8, Date.calculate_mday(2007, 10, :second, 1)
|
|
32
|
+
assert_equal 13, Date.calculate_mday(2008, 10, :second, :monday)
|
|
33
|
+
assert_equal 12, Date.calculate_mday(2009, 10, :second, 1)
|
|
34
|
+
assert_equal 11, Date.calculate_mday(2010, 10, :second, 1)
|
|
35
|
+
|
|
36
|
+
# Misc
|
|
37
|
+
assert_equal 21, Date.calculate_mday(2008, 1, :third, 1)
|
|
38
|
+
assert_equal 1, Date.calculate_mday(2007, 1, :first, 1)
|
|
39
|
+
assert_equal 2, Date.calculate_mday(2007, 3, :first, :friday)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_mday_allows_integers_or_symbols
|
|
43
|
+
assert_nothing_raised do
|
|
44
|
+
Date.calculate_mday(2008, 1, 1, 1)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
assert_nothing_raised do
|
|
48
|
+
Date.calculate_mday(2008, 1, -1, 1)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
assert_nothing_raised do
|
|
52
|
+
Date.calculate_mday(2008, 1, :last, 1)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_mday_requires_valid_week
|
|
57
|
+
assert_raises ArgumentError do
|
|
58
|
+
Date.calculate_mday(2008, 1, :none, 1)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
assert_raises ArgumentError do
|
|
62
|
+
Date.calculate_mday(2008, 1, nil, 1)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
assert_raises ArgumentError do
|
|
66
|
+
Date.calculate_mday(2008, 1, 0, 1)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_mday_requires_valid_day
|
|
71
|
+
assert_raises ArgumentError do
|
|
72
|
+
Date.calculate_mday(2008, 1, 1, :october)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
assert_raises ArgumentError do
|
|
76
|
+
Date.calculate_mday(2008, 1, 1, nil)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
assert_raises ArgumentError do
|
|
80
|
+
Date.calculate_mday(2008, 1, 1, 7)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_holiday?
|
|
85
|
+
assert Date.civil(2008,1,1).holiday?('ca')
|
|
86
|
+
end
|
|
87
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../'))
|
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../lib/'))
|
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../../lib/'))
|
|
4
|
+
|
|
5
|
+
$KCODE = 'u'
|
|
6
|
+
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'test/unit'
|
|
9
|
+
require 'date'
|
|
10
|
+
require 'holidays'
|
|
11
|
+
require 'holidays/ca'
|