holidays 0.9.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.
Files changed (66) hide show
  1. data/LICENSE +21 -0
  2. data/README +76 -0
  3. data/REFERENCES +16 -0
  4. data/data/SYNTAX +111 -0
  5. data/data/au.yaml +106 -0
  6. data/data/build_defs.rb +152 -0
  7. data/data/ca.yaml +141 -0
  8. data/data/de.yaml +115 -0
  9. data/data/dk.yaml +117 -0
  10. data/data/es.yaml +161 -0
  11. data/data/fr.yaml +70 -0
  12. data/data/gb.yaml +106 -0
  13. data/data/ie.yaml +58 -0
  14. data/data/index.yaml +21 -0
  15. data/data/is.yaml +136 -0
  16. data/data/it.yaml +66 -0
  17. data/data/mx.yaml +106 -0
  18. data/data/nl.yaml +67 -0
  19. data/data/north_america_informal.yaml +49 -0
  20. data/data/pt.yaml +85 -0
  21. data/data/se.yaml +91 -0
  22. data/data/united_nations.yaml +188 -0
  23. data/data/us.yaml +81 -0
  24. data/data/za.yaml +78 -0
  25. data/lib/holidays.rb +404 -0
  26. data/lib/holidays/MANIFEST +23 -0
  27. data/lib/holidays/au.rb +41 -0
  28. data/lib/holidays/ca.rb +68 -0
  29. data/lib/holidays/de.rb +52 -0
  30. data/lib/holidays/dk.rb +47 -0
  31. data/lib/holidays/es.rb +52 -0
  32. data/lib/holidays/europe.rb +215 -0
  33. data/lib/holidays/fr.rb +36 -0
  34. data/lib/holidays/gb.rb +40 -0
  35. data/lib/holidays/ie.rb +32 -0
  36. data/lib/holidays/is.rb +61 -0
  37. data/lib/holidays/it.rb +35 -0
  38. data/lib/holidays/mx.rb +51 -0
  39. data/lib/holidays/nl.rb +36 -0
  40. data/lib/holidays/north_america.rb +107 -0
  41. data/lib/holidays/pt.rb +52 -0
  42. data/lib/holidays/scandinavia.rb +114 -0
  43. data/lib/holidays/se.rb +52 -0
  44. data/lib/holidays/united_nations.rb +24 -0
  45. data/lib/holidays/us.rb +48 -0
  46. data/lib/holidays/za.rb +35 -0
  47. data/test/defs/test_defs_au.rb +36 -0
  48. data/test/defs/test_defs_ca.rb +29 -0
  49. data/test/defs/test_defs_de.rb +46 -0
  50. data/test/defs/test_defs_dk.rb +30 -0
  51. data/test/defs/test_defs_es.rb +57 -0
  52. data/test/defs/test_defs_europe.rb +240 -0
  53. data/test/defs/test_defs_fr.rb +26 -0
  54. data/test/defs/test_defs_gb.rb +36 -0
  55. data/test/defs/test_defs_ie.rb +21 -0
  56. data/test/defs/test_defs_is.rb +33 -0
  57. data/test/defs/test_defs_it.rb +25 -0
  58. data/test/defs/test_defs_mx.rb +22 -0
  59. data/test/defs/test_defs_nl.rb +24 -0
  60. data/test/defs/test_defs_north_america.rb +54 -0
  61. data/test/defs/test_defs_pt.rb +32 -0
  62. data/test/defs/test_defs_scandinavia.rb +75 -0
  63. data/test/defs/test_defs_se.rb +32 -0
  64. data/test/defs/test_defs_us.rb +36 -0
  65. data/test/defs/test_defs_za.rb +25 -0
  66. metadata +118 -0
data/data/fr.yaml ADDED
@@ -0,0 +1,70 @@
1
+ # French holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Updated: 2008-11-2*.
4
+ # Sources:
5
+ # - http://en.wikipedia.org/wiki/Holidays_in_France
6
+ # - http://riviera.angloinfo.com/information/1/pub_hols.asp
7
+ ---
8
+ months:
9
+ 0:
10
+ - name: Pâques
11
+ regions: [fr]
12
+ function: easter(year)
13
+ - name: Lundi de Pâques
14
+ regions: [fr]
15
+ function: easter(year)+1
16
+ - name: Ascension
17
+ regions: [fr]
18
+ function: easter(year)+39
19
+ - name: Pentecôte
20
+ regions: [fr]
21
+ function: easter(year)+49
22
+ - name: Lundi de Pentecôte
23
+ regions: [fr]
24
+ function: easter(year)+50
25
+ 1:
26
+ - name: Jour de l'an
27
+ regions: [fr]
28
+ mday: 1
29
+ 5:
30
+ - name: Fête du travail
31
+ regions: [fr]
32
+ mday: 1
33
+ - name: Victoire 1945
34
+ regions: [fr]
35
+ mday: 8
36
+ 7:
37
+ - name: Fête nationale
38
+ regions: [fr]
39
+ mday: 14
40
+ 8:
41
+ - name: Assomption
42
+ regions: [fr]
43
+ mday: 15
44
+ 11:
45
+ - name: Toussaint
46
+ regions: [fr]
47
+ mday: 1
48
+ - name: Armistice 1918
49
+ regions: [fr]
50
+ mday: 11
51
+ 12:
52
+ - name: Nöel
53
+ regions: [fr]
54
+ mday: 25
55
+ tests: |
56
+ {Date.civil(2007,1,1) => 'Jour de l\'an',
57
+ Date.civil(2007,4,8) => 'Pâques',
58
+ Date.civil(2007,4,9) => 'Lundi de Pâques',
59
+ Date.civil(2007,5,1) => 'Fête du travail',
60
+ Date.civil(2007,5,8) => 'Victoire 1945',
61
+ Date.civil(2007,5,17) => 'Ascension',
62
+ Date.civil(2007,5,27) => 'Pentecôte',
63
+ Date.civil(2007,5,28) => 'Lundi de Pentecôte',
64
+ Date.civil(2007,7,14) => 'Fête nationale',
65
+ Date.civil(2007,8,15) => 'Assomption',
66
+ Date.civil(2007,11,1) => 'Toussaint',
67
+ Date.civil(2007,11,11) => 'Armistice 1918',
68
+ Date.civil(2007,12,25) => 'Nöel'}.each do |date, name|
69
+ assert_equal name, Holidays.on(date, :fr, :informal)[0][:name]
70
+ end
data/data/gb.yaml ADDED
@@ -0,0 +1,106 @@
1
+ # Great Britain/United Kingdom holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Including England, Wales, Scotland, N. Ireland, the Isle of Man, Guernsey
4
+ # and Jersey.
5
+ #
6
+ # Updated: 2008-11-28.
7
+ # Sources:
8
+ # - http://en.wikipedia.org/wiki/List_of_holidays_by_country#United_Kingdom_and_Crown_dependencies
9
+ #
10
+ # Notes:
11
+ # - Jersey, Guernsey and the Isle of Man are encode with both their ISO 3166-1 and ISO 3-3166-2 codes.
12
+ # - England and Wales together should be encoded as [gb_eng, gb_wls, gb_eaw...]
13
+ ---
14
+ months:
15
+ 0:
16
+ - name: Good Friday
17
+ regions: [gb]
18
+ function: easter(year)-2
19
+ - name: Easter Sunday
20
+ regions: [gb]
21
+ function: easter(year)
22
+ - name: Easter Monday
23
+ regions: [gb_eng, gb_wls, gb_eaw, gb_nir]
24
+ function: easter(year)+1
25
+ 1:
26
+ - name: New Year's Day
27
+ regions: [gb]
28
+ mday: 1
29
+ - name: New Year's
30
+ regions: [gb_sct]
31
+ mday: 2
32
+ 3:
33
+ - name: St. Piran's Day
34
+ regions: [gb_con]
35
+ mday: 5
36
+ - name: St. Patrick's Day
37
+ regions: [gb_nir]
38
+ mday: 17
39
+ 5:
40
+ - name: May Day
41
+ regions: [gb]
42
+ week: 1
43
+ wday: 1
44
+ - name: Liberation Day
45
+ regions: [je, gb_jsy, gg, gb_gsy]
46
+ mday: 9
47
+ - name: Bank Holiday
48
+ regions: [gb]
49
+ week: -1
50
+ wday: 1
51
+ 7:
52
+ - name: Tynwald Day
53
+ regions: [im, gb_iom]
54
+ mday: 5
55
+ - name: Battle of the Boyne
56
+ regions: [gb_nir]
57
+ mday: 12
58
+ 8:
59
+ - name: Bank Holiday
60
+ regions: [gb_sct]
61
+ week: 1
62
+ wday: 1
63
+ - name: Bank Holiday
64
+ regions: [gb_eng, gb_wls, gb_eaw, gb_nir]
65
+ week: -1
66
+ wday: 1
67
+ 11:
68
+ - name: Guy Fawkes Day
69
+ regions: [gb]
70
+ mday: 5
71
+ type: informal
72
+ 12:
73
+ - name: Christmas Day
74
+ regions: [gb]
75
+ mday: 25
76
+ observed: to_monday_if_weekend
77
+ - name: Boxing Day
78
+ regions: [gb]
79
+ mday: 26
80
+ observed: to_weekday_if_boxing_weekend
81
+ tests: |
82
+ {Date.civil(2008,1,1) => 'New Year\'s Day',
83
+ Date.civil(2008,3,21) => 'Good Friday',
84
+ Date.civil(2008,3,23) => 'Easter Sunday',
85
+ Date.civil(2008,5,5) => 'May Day',
86
+ Date.civil(2008,5,26) => 'Bank Holiday',
87
+ Date.civil(2008,11,5) => 'Guy Fawkes Day',
88
+ Date.civil(2008,12,25) => 'Christmas Day',
89
+ Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
90
+ assert_equal name, Holidays.on(date, :gb, :informal)[0][:name]
91
+ end
92
+
93
+ assert_equal 'St. Patrick\'s Day', Date.civil(2008,3,17).holidays(:gb_nir, :informal)[0][:name]
94
+
95
+ assert_equal 'Christmas Day', Date.civil(2008,12,25).holidays(:gb_, :observed)[0][:name]
96
+ assert_equal 'Christmas Day', Date.civil(2009,12,25).holidays(:gb_, :observed)[0][:name]
97
+ assert_equal 'Christmas Day', Date.civil(2010,12,27).holidays(:gb_, :observed)[0][:name]
98
+
99
+ assert_equal 'Boxing Day', Date.civil(2008,12,26).holidays(:gb_, :observed)[0][:name]
100
+ assert_equal 'Boxing Day', Date.civil(2009,12,28).holidays(:gb_, :observed)[0][:name]
101
+ assert_equal 'Boxing Day', Date.civil(2010,12,28).holidays(:gb_, :observed)[0][:name]
102
+
103
+ [:gb_wls, :gb_eng, :gb_nir, :gb_eaw, :gb_].each do |r|
104
+ assert_equal 'Easter Monday', Date.civil(2008,3,24).holidays(r)[0][:name]
105
+ assert_equal 'Bank Holiday', Date.civil(2008,8,25).holidays(r)[0][:name]
106
+ end
data/data/ie.yaml ADDED
@@ -0,0 +1,58 @@
1
+ # Ireland holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Updated: 2008-11-28.
4
+ # Sources:
5
+ # - http://en.wikipedia.org/wiki/Public_holidays_in_the_Republic_of_Ireland
6
+ # - http://www.citizensinformation.ie/categories/employment/employment-rights-and-conditions/leave-and-holidays/public-holidays-in-ireland
7
+ ---
8
+ months:
9
+ 0:
10
+ - name: Easter Monday
11
+ regions: [ie]
12
+ function: easter(year)+1
13
+ 1:
14
+ - name: New Year's Day
15
+ regions: [ie]
16
+ mday: 1
17
+ 3:
18
+ - name: St. Patrick's Day
19
+ regions: [ie]
20
+ mday: 17
21
+ 5:
22
+ - name: May Day
23
+ regions: [ie]
24
+ week: 1
25
+ wday: 1
26
+ 6:
27
+ - name: Bank Holiday
28
+ regions: [ie]
29
+ week: 1
30
+ wday: 1
31
+ 8:
32
+ - name: Bank Holiday
33
+ regions: [ie]
34
+ week: 1
35
+ wday: 1
36
+ 10:
37
+ - name: Bank Holiday
38
+ regions: [ie]
39
+ week: -1
40
+ wday: 1
41
+ 12:
42
+ - name: Christmas Day
43
+ regions: [ie]
44
+ mday: 25
45
+ - name: St. Stephen's Day
46
+ regions: [ie]
47
+ mday: 26
48
+ tests: |
49
+ {Date.civil(2008,1,1) => 'New Year\'s Day',
50
+ Date.civil(2008,3,17) => 'St. Patrick\'s Day',
51
+ Date.civil(2008,3,24) => 'Easter Monday',
52
+ Date.civil(2008,5,5) => 'May Day',
53
+ Date.civil(2008,6,2) => 'Bank Holiday',
54
+ Date.civil(2008,8,4) => 'Bank Holiday',
55
+ Date.civil(2008,12,25) => 'Christmas Day',
56
+ Date.civil(2008,12,26) => 'St. Stephen\'s Day'}.each do |date, name|
57
+ assert_equal name, Holidays.on(date, :ie, :informal)[0][:name]
58
+ end
data/data/index.yaml ADDED
@@ -0,0 +1,21 @@
1
+ # Definition build list
2
+ ---
3
+ defs:
4
+ AU: ['au.yaml']
5
+ CA: ['ca.yaml', 'north_america_informal.yaml']
6
+ DK: ['dk.yaml']
7
+ DE: ['de.yaml']
8
+ ES: ['es.yaml']
9
+ FR: ['fr.yaml']
10
+ GB: ['gb.yaml']
11
+ IE: ['ie.yaml']
12
+ IS: ['is.yaml']
13
+ IT: ['it.yaml']
14
+ MX: ['mx.yaml', 'north_america_informal.yaml']
15
+ NL: ['nl.yaml']
16
+ PT: ['se.yaml']
17
+ US: ['au.yaml', 'north_america_informal.yaml']
18
+ United_Nations: ['united_nations.yaml']
19
+ ZA: ['za.yaml']
20
+ North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml']
21
+ Europe: ['dk.yaml', 'de.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'nl.yaml', 'pt.yaml']
data/data/is.yaml ADDED
@@ -0,0 +1,136 @@
1
+ # Icelandic holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Updated: 2008-11-29.
4
+ # Sources:
5
+ # - http://www.simnet.is/gardarj/folk/days.htm#days
6
+ # - http://www.iceland.is/history-and-culture/Traditions/IcelandicHolidays/
7
+ # - http://en.wikipedia.org/wiki/Public_holidays_in_Iceland
8
+ # - http://www.qppstudio.net/publicholidays2007/iceland.htm
9
+ ---
10
+ months:
11
+ 0:
12
+ - name: Bolludagur
13
+ regions: [is]
14
+ function: easter(year)-48
15
+ - name: Sprengidagur
16
+ regions: [is]
17
+ function: easter(year)-47
18
+ - name: Öskudagur
19
+ regions: [is]
20
+ function: easter(year)-46
21
+ - name: Pálmasunnudagur
22
+ regions: [is]
23
+ function: easter(year)-7
24
+ - name: Skírdagur
25
+ regions: [is]
26
+ function: easter(year)-3
27
+ - name: Föstudaginn langi
28
+ regions: [is]
29
+ function: easter(year)-2
30
+ - name: Páskadagur
31
+ regions: [is]
32
+ function: easter(year)
33
+ - name: Annar í páskum
34
+ regions: [is]
35
+ function: easter(year)+1
36
+ - name: Uppstigningardagur
37
+ regions: [is]
38
+ function: easter(year)+39
39
+ - name: Hvítasunnudagur
40
+ regions: [is]
41
+ function: easter(year)+49
42
+ - name: Annar í hvítasunnu
43
+ regions: [is]
44
+ function: easter(year)+50
45
+ 1:
46
+ - name: Nýársdagur
47
+ regions: [is]
48
+ mday: 1
49
+ - name: Þrettándinn
50
+ regions: [is]
51
+ mday: 6
52
+ - name: Bóndadagur
53
+ regions: [is]
54
+ mday: 19
55
+ type: informal
56
+ 2:
57
+ - name: Konudagur
58
+ regions: [is]
59
+ mday: 18
60
+ type: informal
61
+ 4:
62
+ - name: Sumardagurinn fyrsti
63
+ regions: [is]
64
+ function: is_sumardagurinn_fyrsti(year)
65
+ 5:
66
+ - name: Verkalýðsdagurinn
67
+ regions: [is]
68
+ mday: 1
69
+ - name: Mæðradagurinn
70
+ regions: [is]
71
+ mday: 13
72
+ 6:
73
+ - name: Sjómannadagurinn
74
+ regions: [is]
75
+ mday: 3
76
+ type: informal
77
+ - name: Lýðveldisdagurinn
78
+ regions: [is]
79
+ mday: 17
80
+ 8:
81
+ - name: Frídagur verslunarmanna
82
+ regions: [is]
83
+ week: 1
84
+ wday: 1
85
+ 11:
86
+ - name: Dagur íslenskrar tungu
87
+ regions: [is]
88
+ mday: 16
89
+ 12:
90
+ - name: Jól
91
+ regions: [is]
92
+ mday: 24
93
+ - name: Jól
94
+ regions: [is]
95
+ mday: 25
96
+ - name: Jól
97
+ regions: [is]
98
+ mday: 26
99
+ - name: Gamlárskvöld
100
+ regions: [is]
101
+ mday: 31
102
+ methods:
103
+ is_sumardagurinn_fyrsti: |
104
+ # Iceland: first day of summer (Thursday after 18 April)
105
+ def self.is_sumardagurinn_fyrsti(year)
106
+ date = Date.civil(year,4,18)
107
+ if date.wday < 4
108
+ date += (4 - date.wday)
109
+ else date
110
+ date += (11 - date.wday)
111
+ end
112
+ date
113
+ end
114
+ tests: |
115
+ {Date.civil(2007,1,1) => 'Nýársdagur',
116
+ Date.civil(2007,1,6) => 'Þrettándinn',
117
+ Date.civil(2007,1,19) => 'Bóndadagur',
118
+ Date.civil(2007,2,18) => 'Konudagur',
119
+ Date.civil(2007,4,5) => 'Skírdagur',
120
+ Date.civil(2007,4,6) => 'Föstudaginn langi',
121
+ Date.civil(2007,4,8) => 'Páskadagur',
122
+ Date.civil(2007,4,9) => 'Annar í páskum',
123
+ Date.civil(2007,4,19) => 'Sumardagurinn fyrsti',
124
+ Date.civil(2007,5,1) => 'Verkalýðsdagurinn',
125
+ Date.civil(2007,5,17) => 'Uppstigningardagur',
126
+ Date.civil(2007,5,27) => 'Hvítasunnudagur',
127
+ Date.civil(2007,5,28) => 'Annar í hvítasunnu',
128
+ Date.civil(2007,6,3) => 'Sjómannadagurinn',
129
+ Date.civil(2007,6,17) => 'Lýðveldisdagurinn',
130
+ Date.civil(2007,8,6) => 'Frídagur verslunarmanna',
131
+ Date.civil(2007,12,24) => 'Jól',
132
+ Date.civil(2007,12,25) => 'Jól',
133
+ Date.civil(2007,12,26) => 'Jól',
134
+ Date.civil(2007,12,31) => 'Gamlárskvöld'}.each do |date, name|
135
+ assert_equal name, Holidays.on(date, :is, :informal)[0][:name]
136
+ end
data/data/it.yaml ADDED
@@ -0,0 +1,66 @@
1
+ # Italian holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Updated: 2008-11-23.
4
+ # Sources:
5
+ # - http://en.wikipedia.org/wiki/Holidays_in_Italy
6
+ ---
7
+ months:
8
+ 0:
9
+ - name: Pasqua
10
+ regions: [it]
11
+ function: easter(year)
12
+ - name: Lunedì dell'Angelo
13
+ regions: [it]
14
+ function: easter(year)+1
15
+ 1:
16
+ - name: Capodanno
17
+ regions: [it]
18
+ mday: 1
19
+ - name: Epifania
20
+ regions: [it]
21
+ mday: 6
22
+ 4:
23
+ - name: Festa della Liberazione
24
+ regions: [it]
25
+ mday: 25
26
+ 5:
27
+ - name: Festa dei Lavoratori
28
+ regions: [it]
29
+ mday: 1
30
+ 6:
31
+ - name: Festa della Repubblica
32
+ regions: [it]
33
+ mday: 2
34
+ 8:
35
+ - name: Assunzione
36
+ regions: [it]
37
+ mday: 15
38
+ 11:
39
+ - name: Ognissanti
40
+ regions: [it]
41
+ mday: 1
42
+ 12:
43
+ - name: Immacolata Concezione
44
+ regions: [it]
45
+ mday: 8
46
+ - name: Natale
47
+ regions: [it]
48
+ mday: 25
49
+ - name: Santo Stefano
50
+ regions: [it]
51
+ mday: 26
52
+ tests: |
53
+ {Date.civil(2007,1,1) => 'Capodanno',
54
+ Date.civil(2007,1,6) => 'Epifania',
55
+ Date.civil(2007,4,8) => 'Pasqua',
56
+ Date.civil(2007,4,9) => 'Lunedì dell\'Angelo',
57
+ Date.civil(2007,4,25) => 'Festa della Liberazione',
58
+ Date.civil(2007,5,1) => 'Festa dei Lavoratori',
59
+ Date.civil(2007,6,2) => 'Festa della Repubblica',
60
+ Date.civil(2007,8,15) => 'Assunzione',
61
+ Date.civil(2007,11,1) => 'Ognissanti',
62
+ Date.civil(2007,12,8) => 'Immacolata Concezione',
63
+ Date.civil(2007,12,25) => 'Natale',
64
+ Date.civil(2007,12,26) => 'Santo Stefano'}.each do |date, name|
65
+ assert_equal name, Holidays.on(date, :it, :informal)[0][:name]
66
+ end