wombleton-holidays 0.9.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.
- data/.gitignore +3 -0
- data/CHANGELOG +22 -0
- data/LICENSE +21 -0
- data/README.rdoc +77 -0
- data/REFERENCES +16 -0
- data/VERSION +1 -0
- data/data/SYNTAX +111 -0
- data/data/au.yaml +111 -0
- data/data/build_defs.rb +152 -0
- data/data/ca.yaml +141 -0
- data/data/cz.yaml +68 -0
- data/data/de.yaml +111 -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 +26 -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/no.yaml +82 -0
- data/data/north_america_informal.yaml +49 -0
- data/data/nyse.yaml +63 -0
- data/data/nz.yaml +141 -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/holidays.gemspec +16 -0
- data/lib/holidays/MANIFEST +28 -0
- data/lib/holidays/au.rb +43 -0
- data/lib/holidays/ca.rb +69 -0
- data/lib/holidays/cz.rb +36 -0
- data/lib/holidays/de.rb +51 -0
- data/lib/holidays/dk.rb +48 -0
- data/lib/holidays/es.rb +53 -0
- data/lib/holidays/europe.rb +236 -0
- data/lib/holidays/fr.rb +37 -0
- data/lib/holidays/gb.rb +41 -0
- data/lib/holidays/ie.rb +33 -0
- data/lib/holidays/is.rb +62 -0
- data/lib/holidays/it.rb +36 -0
- data/lib/holidays/mx.rb +52 -0
- data/lib/holidays/nl.rb +37 -0
- data/lib/holidays/no.rb +40 -0
- data/lib/holidays/north_america.rb +108 -0
- data/lib/holidays/nyse.rb +33 -0
- data/lib/holidays/nz.rb +69 -0
- data/lib/holidays/pt.rb +38 -0
- data/lib/holidays/scandinavia.rb +115 -0
- data/lib/holidays/se.rb +53 -0
- data/lib/holidays/united_nations.rb +25 -0
- data/lib/holidays/ups.rb +32 -0
- data/lib/holidays/us.rb +49 -0
- data/lib/holidays/za.rb +36 -0
- data/lib/holidays.rb +408 -0
- data/rakefile.rb +103 -0
- data/test/defs/test_defs_au.rb +35 -0
- data/test/defs/test_defs_ca.rb +28 -0
- data/test/defs/test_defs_cz.rb +25 -0
- data/test/defs/test_defs_de.rb +48 -0
- data/test/defs/test_defs_dk.rb +29 -0
- data/test/defs/test_defs_es.rb +56 -0
- data/test/defs/test_defs_europe.rb +277 -0
- data/test/defs/test_defs_fr.rb +25 -0
- data/test/defs/test_defs_gb.rb +35 -0
- data/test/defs/test_defs_ie.rb +20 -0
- data/test/defs/test_defs_is.rb +32 -0
- data/test/defs/test_defs_it.rb +24 -0
- data/test/defs/test_defs_mx.rb +21 -0
- data/test/defs/test_defs_nl.rb +23 -0
- data/test/defs/test_defs_no.rb +28 -0
- data/test/defs/test_defs_north_america.rb +53 -0
- data/test/defs/test_defs_nyse.rb +21 -0
- data/test/defs/test_defs_nz.rb +21 -0
- data/test/defs/test_defs_pt.rb +31 -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 +20 -0
- data/test/defs/test_defs_us.rb +22 -0
- data/test/defs/test_defs_za.rb +24 -0
- data/test/test_date.rb +101 -0
- data/test/test_helper.rb +11 -0
- data/test/test_holidays.rb +117 -0
- data/test/test_multiple_regions.rb +20 -0
- metadata +172 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
|
4
|
+
#
|
|
5
|
+
# Definitions loaded: data/pt.yaml
|
|
6
|
+
class PtDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
7
|
+
|
|
8
|
+
def test_pt
|
|
9
|
+
{Date.civil(2008,1,1) => 'Ano Novo',
|
|
10
|
+
Date.civil(2005,2,8) => 'Carnaval',
|
|
11
|
+
Date.civil(2006,2,28) => 'Carnaval',
|
|
12
|
+
Date.civil(2007,2,20) => 'Carnaval',
|
|
13
|
+
Date.civil(2008,2,5) => 'Carnaval',
|
|
14
|
+
Date.civil(2008,3,21) => 'Sexta-feira Santa',
|
|
15
|
+
Date.civil(2008,3,23) => 'Páscoa',
|
|
16
|
+
Date.civil(2008,4,25) => 'Dia da Liberdade',
|
|
17
|
+
Date.civil(2008,5,1) => 'Dia do Trabalhador',
|
|
18
|
+
Date.civil(2005,5,26) => 'Corpo de Deus',
|
|
19
|
+
Date.civil(2007,6,7) => 'Corpo de Deus',
|
|
20
|
+
Date.civil(2008,5,22) => 'Corpo de Deus',
|
|
21
|
+
Date.civil(2008,6,10) => 'Dia de Portugal',
|
|
22
|
+
Date.civil(2008,8,15) => 'Assunção de Nossa Senhora',
|
|
23
|
+
Date.civil(2008,10,5) => 'Implantação da República',
|
|
24
|
+
Date.civil(2008,11,1) => 'Todos os Santos',
|
|
25
|
+
Date.civil(2008,12,1) => 'Restauração da Independência',
|
|
26
|
+
Date.civil(2008,12,8) => 'Imaculada Conceição',
|
|
27
|
+
Date.civil(2008,12,25) => 'Natal'}.each do |date, name|
|
|
28
|
+
assert_equal name, (Holidays.on(date, :pt, :informal)[0] || {})[:name]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
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,20 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
|
4
|
+
#
|
|
5
|
+
# Definitions loaded: data/ups.yaml
|
|
6
|
+
class UpsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
7
|
+
|
|
8
|
+
def test_ups
|
|
9
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
10
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
|
11
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
|
12
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
|
13
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
|
14
|
+
Date.civil(2008,11,28) => 'Day After Thanksgiving',
|
|
15
|
+
Date.civil(2008,12,25) => 'Christmas Day',
|
|
16
|
+
Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
|
|
17
|
+
assert_equal name, (Holidays.on(date, :ups)[0] || {})[:name]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
|
4
|
+
#
|
|
5
|
+
# Definitions loaded: data/us.yaml, data/north_america_informal.yaml
|
|
6
|
+
class UsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
7
|
+
|
|
8
|
+
def test_us
|
|
9
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
|
10
|
+
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
|
11
|
+
Date.civil(2008,2,18) => 'Presidents\' Day',
|
|
12
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
|
13
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
|
14
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
|
15
|
+
Date.civil(2008,10,13) => 'Columbus Day',
|
|
16
|
+
Date.civil(2008,11,11) => 'Veterans 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, :us)[0] || {})[:name]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
# This file is generated by the Ruby Holiday gem.
|
|
4
|
+
#
|
|
5
|
+
# Definitions loaded: data/za.yaml
|
|
6
|
+
class ZaDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
7
|
+
|
|
8
|
+
def test_za
|
|
9
|
+
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
|
10
|
+
Date.civil(2007,3,21) => 'Human Rights Day',
|
|
11
|
+
Date.civil(2007,4,6) => 'Good Friday',
|
|
12
|
+
Date.civil(2007,4,9) => 'Family Day',
|
|
13
|
+
Date.civil(2007,4,27) => 'Freedom Day',
|
|
14
|
+
Date.civil(2007,5,1) => 'Workers Day',
|
|
15
|
+
Date.civil(2007,6,16) => 'Youth Day',
|
|
16
|
+
Date.civil(2007,8,9) => 'National Women\'s Day',
|
|
17
|
+
Date.civil(2007,9,24) => 'Heritage Day',
|
|
18
|
+
Date.civil(2007,12,16) => 'Day of Reconciliation',
|
|
19
|
+
Date.civil(2007,12,25) => 'Christmas Day',
|
|
20
|
+
Date.civil(2007,12,26) => 'Day of Goodwill'}.each do |date, name|
|
|
21
|
+
assert_equal name, (Holidays.on(date, :za, :informal)[0] || {})[:name]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/test/test_date.rb
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
assert_equal 30, Date.calculate_mday(2012, 1, :last, 1)
|
|
41
|
+
assert_equal 29, Date.calculate_mday(2016, 2, :last, 1)
|
|
42
|
+
|
|
43
|
+
# From end of month
|
|
44
|
+
assert_equal 26, Date.calculate_mday(2009, 8, -1, :wednesday)
|
|
45
|
+
assert_equal 19, Date.calculate_mday(2009, 8, -2, :wednesday)
|
|
46
|
+
assert_equal 12, Date.calculate_mday(2009, 8, -3, :wednesday)
|
|
47
|
+
|
|
48
|
+
assert_equal 13, Date.calculate_mday(2008, 8, -3, :wednesday)
|
|
49
|
+
assert_equal 12, Date.calculate_mday(2009, 8, -3, :wednesday)
|
|
50
|
+
assert_equal 11, Date.calculate_mday(2010, 8, -3, :wednesday)
|
|
51
|
+
assert_equal 17, Date.calculate_mday(2011, 8, -3, :wednesday)
|
|
52
|
+
assert_equal 15, Date.calculate_mday(2012, 8, -3, :wednesday)
|
|
53
|
+
assert_equal 14, Date.calculate_mday(2013, 8, -3, :wednesday)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_mday_allows_integers_or_symbols
|
|
57
|
+
assert_nothing_raised do
|
|
58
|
+
Date.calculate_mday(2008, 1, 1, 1)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
assert_nothing_raised do
|
|
62
|
+
Date.calculate_mday(2008, 1, -1, 1)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
assert_nothing_raised do
|
|
66
|
+
Date.calculate_mday(2008, 1, :last, 1)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_mday_requires_valid_week
|
|
71
|
+
assert_raises ArgumentError do
|
|
72
|
+
Date.calculate_mday(2008, 1, :none, 1)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
assert_raises ArgumentError do
|
|
76
|
+
Date.calculate_mday(2008, 1, nil, 1)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
assert_raises ArgumentError do
|
|
80
|
+
Date.calculate_mday(2008, 1, 0, 1)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_mday_requires_valid_day
|
|
85
|
+
assert_raises ArgumentError do
|
|
86
|
+
Date.calculate_mday(2008, 1, 1, :october)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
assert_raises ArgumentError do
|
|
90
|
+
Date.calculate_mday(2008, 1, 1, nil)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
assert_raises ArgumentError do
|
|
94
|
+
Date.calculate_mday(2008, 1, 1, 7)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_holiday?
|
|
99
|
+
assert Date.civil(2008,1,1).holiday?('ca')
|
|
100
|
+
end
|
|
101
|
+
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'
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
require 'holidays/ca'
|
|
4
|
+
|
|
5
|
+
# Re-include CA defs via holidays/north_america to ensure that individual
|
|
6
|
+
# defs aren't duplicated.
|
|
7
|
+
require 'holidays/north_america'
|
|
8
|
+
|
|
9
|
+
class HolidaysTests < Test::Unit::TestCase
|
|
10
|
+
def setup
|
|
11
|
+
@date = Date.civil(2008,1,1)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_on
|
|
15
|
+
h = Holidays.on(Date.civil(2008,9,1), :ca)
|
|
16
|
+
assert_equal 'Labour Day', h[0][:name]
|
|
17
|
+
|
|
18
|
+
holidays = Holidays.on(Date.civil(2008,7,4), :ca)
|
|
19
|
+
assert_equal 0, holidays.length
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_between
|
|
23
|
+
holidays = Holidays.between(Date.civil(2008,7,1), Date.civil(2008,7,1), :ca)
|
|
24
|
+
assert_equal 1, holidays.length
|
|
25
|
+
|
|
26
|
+
holidays = Holidays.between(Date.civil(2008,7,1), Date.civil(2008,7,31), :ca)
|
|
27
|
+
assert_equal 1, holidays.length
|
|
28
|
+
|
|
29
|
+
holidays = Holidays.between(Date.civil(2008,7,2), Date.civil(2008,7,31), :ca)
|
|
30
|
+
assert_equal 0, holidays.length
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_requires_valid_regions
|
|
34
|
+
assert_raises Holidays::UnknownRegionError do
|
|
35
|
+
Holidays.on(Date.civil(2008,1,1), :xx)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
assert_raises Holidays::UnknownRegionError do
|
|
39
|
+
Holidays.on(Date.civil(2008,1,1), [:ca,:xx])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
assert_raises Holidays::UnknownRegionError do
|
|
43
|
+
Holidays.between(Date.civil(2008,1,1), Date.civil(2008,12,31), [:ca,:xx])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_region_params
|
|
48
|
+
holidays = Holidays.on(@date, :ca)
|
|
49
|
+
assert_equal 1, holidays.length
|
|
50
|
+
|
|
51
|
+
holidays = Holidays.on(@date, [:ca_bc,:ca])
|
|
52
|
+
assert_equal 1, holidays.length
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_observed_dates
|
|
56
|
+
# Should fall on Tuesday the 1st
|
|
57
|
+
assert_equal 1, Holidays.on(Date.civil(2008,7,1), :ca, :observed).length
|
|
58
|
+
|
|
59
|
+
# Should fall on Monday the 2nd
|
|
60
|
+
assert_equal 1, Holidays.on(Date.civil(2007,7,2), :ca, :observed).length
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_any_region
|
|
64
|
+
# Should return Victoria Day.
|
|
65
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
|
66
|
+
assert_equal 1, holidays.length
|
|
67
|
+
|
|
68
|
+
# Should return Victoria Day and National Patriotes Day.
|
|
69
|
+
#
|
|
70
|
+
# Should be 2 in the CA region but other regional files are loaded during the
|
|
71
|
+
# unit tests add to the :any count.
|
|
72
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), [:any])
|
|
73
|
+
assert holidays.length >= 2
|
|
74
|
+
|
|
75
|
+
# Test blank region
|
|
76
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31))
|
|
77
|
+
assert holidays.length >= 3
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_sub_regions
|
|
81
|
+
# Should return Victoria Day.
|
|
82
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
|
83
|
+
assert_equal 1, holidays.length
|
|
84
|
+
|
|
85
|
+
# Should return Victoria Da and National Patriotes Day.
|
|
86
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_qc)
|
|
87
|
+
assert 2, holidays.length
|
|
88
|
+
|
|
89
|
+
# Should return Victoria Day and National Patriotes Day.
|
|
90
|
+
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_)
|
|
91
|
+
assert_equal 2, holidays.length
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_easter_sunday
|
|
95
|
+
assert_equal '1800-04-13', Holidays.easter(1800).to_s
|
|
96
|
+
assert_equal '1899-04-02', Holidays.easter(1899).to_s
|
|
97
|
+
assert_equal '1900-04-15', Holidays.easter(1900).to_s
|
|
98
|
+
assert_equal '1999-04-04', Holidays.easter(1999).to_s
|
|
99
|
+
assert_equal '2000-04-23', Holidays.easter(2000).to_s
|
|
100
|
+
assert_equal '2025-04-20', Holidays.easter(2025).to_s
|
|
101
|
+
assert_equal '2035-03-25', Holidays.easter(2035).to_s
|
|
102
|
+
assert_equal '2067-04-03', Holidays.easter(2067).to_s
|
|
103
|
+
assert_equal '2099-04-12', Holidays.easter(2099).to_s
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_easter_lambda
|
|
107
|
+
[Date.civil(1800,4,11), Date.civil(1899,3,31), Date.civil(1900,4,13),
|
|
108
|
+
Date.civil(2008,3,21), Date.civil(2035,3,23)].each do |date|
|
|
109
|
+
assert_equal 'Good Friday', Holidays.on(date, :ca)[0][:name]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
[Date.civil(1800,4,14), Date.civil(1899,4,3), Date.civil(1900,4,16),
|
|
113
|
+
Date.civil(2008,3,24), Date.civil(2035,3,26)].each do |date|
|
|
114
|
+
assert_equal 'Easter Monday', Holidays.on(date, :ca_qc, :informal)[0][:name]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
require 'holidays/gb'
|
|
3
|
+
require 'holidays/ie'
|
|
4
|
+
|
|
5
|
+
class MultipleRegionsTests < Test::Unit::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
@date = Date.civil(2008,1,1)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_defining_holidays
|
|
11
|
+
h = Holidays.on(Date.civil(2008,12,26), :ie)
|
|
12
|
+
assert_equal 'St. Stephen\'s Day', h[0][:name]
|
|
13
|
+
|
|
14
|
+
h = Holidays.on(Date.civil(2008,5,9), :je)
|
|
15
|
+
assert_equal 'Liberation Day', h[0][:name]
|
|
16
|
+
|
|
17
|
+
h = Holidays.on(Date.civil(2008,5,9), :gb)
|
|
18
|
+
assert h.empty?
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wombleton-holidays
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.9.6
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alex Dunae
|
|
8
|
+
- Rowan Crawford
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2010-04-29 00:00:00 +12:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies: []
|
|
16
|
+
|
|
17
|
+
description: A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
|
|
18
|
+
email: wombleton@gmail.com
|
|
19
|
+
executables: []
|
|
20
|
+
|
|
21
|
+
extensions: []
|
|
22
|
+
|
|
23
|
+
extra_rdoc_files:
|
|
24
|
+
- LICENSE
|
|
25
|
+
- README.rdoc
|
|
26
|
+
files:
|
|
27
|
+
- .gitignore
|
|
28
|
+
- CHANGELOG
|
|
29
|
+
- LICENSE
|
|
30
|
+
- README.rdoc
|
|
31
|
+
- REFERENCES
|
|
32
|
+
- VERSION
|
|
33
|
+
- data/SYNTAX
|
|
34
|
+
- data/au.yaml
|
|
35
|
+
- data/build_defs.rb
|
|
36
|
+
- data/ca.yaml
|
|
37
|
+
- data/cz.yaml
|
|
38
|
+
- data/de.yaml
|
|
39
|
+
- data/dk.yaml
|
|
40
|
+
- data/es.yaml
|
|
41
|
+
- data/fr.yaml
|
|
42
|
+
- data/gb.yaml
|
|
43
|
+
- data/ie.yaml
|
|
44
|
+
- data/index.yaml
|
|
45
|
+
- data/is.yaml
|
|
46
|
+
- data/it.yaml
|
|
47
|
+
- data/mx.yaml
|
|
48
|
+
- data/nl.yaml
|
|
49
|
+
- data/no.yaml
|
|
50
|
+
- data/north_america_informal.yaml
|
|
51
|
+
- data/nyse.yaml
|
|
52
|
+
- data/nz.yaml
|
|
53
|
+
- data/pt.yaml
|
|
54
|
+
- data/se.yaml
|
|
55
|
+
- data/united_nations.yaml
|
|
56
|
+
- data/ups.yaml
|
|
57
|
+
- data/us.yaml
|
|
58
|
+
- data/za.yaml
|
|
59
|
+
- holidays.gemspec
|
|
60
|
+
- lib/holidays.rb
|
|
61
|
+
- lib/holidays/MANIFEST
|
|
62
|
+
- lib/holidays/au.rb
|
|
63
|
+
- lib/holidays/ca.rb
|
|
64
|
+
- lib/holidays/cz.rb
|
|
65
|
+
- lib/holidays/de.rb
|
|
66
|
+
- lib/holidays/dk.rb
|
|
67
|
+
- lib/holidays/es.rb
|
|
68
|
+
- lib/holidays/europe.rb
|
|
69
|
+
- lib/holidays/fr.rb
|
|
70
|
+
- lib/holidays/gb.rb
|
|
71
|
+
- lib/holidays/ie.rb
|
|
72
|
+
- lib/holidays/is.rb
|
|
73
|
+
- lib/holidays/it.rb
|
|
74
|
+
- lib/holidays/mx.rb
|
|
75
|
+
- lib/holidays/nl.rb
|
|
76
|
+
- lib/holidays/no.rb
|
|
77
|
+
- lib/holidays/north_america.rb
|
|
78
|
+
- lib/holidays/nyse.rb
|
|
79
|
+
- lib/holidays/nz.rb
|
|
80
|
+
- lib/holidays/pt.rb
|
|
81
|
+
- lib/holidays/scandinavia.rb
|
|
82
|
+
- lib/holidays/se.rb
|
|
83
|
+
- lib/holidays/united_nations.rb
|
|
84
|
+
- lib/holidays/ups.rb
|
|
85
|
+
- lib/holidays/us.rb
|
|
86
|
+
- lib/holidays/za.rb
|
|
87
|
+
- rakefile.rb
|
|
88
|
+
- test/defs/test_defs_au.rb
|
|
89
|
+
- test/defs/test_defs_ca.rb
|
|
90
|
+
- test/defs/test_defs_cz.rb
|
|
91
|
+
- test/defs/test_defs_de.rb
|
|
92
|
+
- test/defs/test_defs_dk.rb
|
|
93
|
+
- test/defs/test_defs_es.rb
|
|
94
|
+
- test/defs/test_defs_europe.rb
|
|
95
|
+
- test/defs/test_defs_fr.rb
|
|
96
|
+
- test/defs/test_defs_gb.rb
|
|
97
|
+
- test/defs/test_defs_ie.rb
|
|
98
|
+
- test/defs/test_defs_is.rb
|
|
99
|
+
- test/defs/test_defs_it.rb
|
|
100
|
+
- test/defs/test_defs_mx.rb
|
|
101
|
+
- test/defs/test_defs_nl.rb
|
|
102
|
+
- test/defs/test_defs_no.rb
|
|
103
|
+
- test/defs/test_defs_north_america.rb
|
|
104
|
+
- test/defs/test_defs_nyse.rb
|
|
105
|
+
- test/defs/test_defs_nz.rb
|
|
106
|
+
- test/defs/test_defs_pt.rb
|
|
107
|
+
- test/defs/test_defs_scandinavia.rb
|
|
108
|
+
- test/defs/test_defs_se.rb
|
|
109
|
+
- test/defs/test_defs_ups.rb
|
|
110
|
+
- test/defs/test_defs_us.rb
|
|
111
|
+
- test/defs/test_defs_za.rb
|
|
112
|
+
- test/test_date.rb
|
|
113
|
+
- test/test_helper.rb
|
|
114
|
+
- test/test_holidays.rb
|
|
115
|
+
- test/test_multiple_regions.rb
|
|
116
|
+
has_rdoc: true
|
|
117
|
+
homepage: http://github.com/wombleton/holidays
|
|
118
|
+
licenses: []
|
|
119
|
+
|
|
120
|
+
post_install_message:
|
|
121
|
+
rdoc_options:
|
|
122
|
+
- --charset=UTF-8
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: "0"
|
|
130
|
+
version:
|
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: "0"
|
|
136
|
+
version:
|
|
137
|
+
requirements: []
|
|
138
|
+
|
|
139
|
+
rubyforge_project:
|
|
140
|
+
rubygems_version: 1.3.5
|
|
141
|
+
signing_key:
|
|
142
|
+
specification_version: 3
|
|
143
|
+
summary: A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
|
|
144
|
+
test_files:
|
|
145
|
+
- test/test_helper.rb
|
|
146
|
+
- test/test_date.rb
|
|
147
|
+
- test/test_multiple_regions.rb
|
|
148
|
+
- test/defs/test_defs_au.rb
|
|
149
|
+
- test/defs/test_defs_no.rb
|
|
150
|
+
- test/defs/test_defs_ups.rb
|
|
151
|
+
- test/defs/test_defs_nyse.rb
|
|
152
|
+
- test/defs/test_defs_scandinavia.rb
|
|
153
|
+
- test/defs/test_defs_dk.rb
|
|
154
|
+
- test/defs/test_defs_se.rb
|
|
155
|
+
- test/defs/test_defs_north_america.rb
|
|
156
|
+
- test/defs/test_defs_europe.rb
|
|
157
|
+
- test/defs/test_defs_nl.rb
|
|
158
|
+
- test/defs/test_defs_fr.rb
|
|
159
|
+
- test/defs/test_defs_us.rb
|
|
160
|
+
- test/defs/test_defs_it.rb
|
|
161
|
+
- test/defs/test_defs_ca.rb
|
|
162
|
+
- test/defs/test_defs_mx.rb
|
|
163
|
+
- test/defs/test_defs_es.rb
|
|
164
|
+
- test/defs/test_defs_de.rb
|
|
165
|
+
- test/defs/test_defs_cz.rb
|
|
166
|
+
- test/defs/test_defs_pt.rb
|
|
167
|
+
- test/defs/test_defs_is.rb
|
|
168
|
+
- test/defs/test_defs_nz.rb
|
|
169
|
+
- test/defs/test_defs_za.rb
|
|
170
|
+
- test/defs/test_defs_gb.rb
|
|
171
|
+
- test/defs/test_defs_ie.rb
|
|
172
|
+
- test/test_holidays.rb
|