holidays 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/README.md +18 -9
  4. data/definitions/README.md +174 -0
  5. data/definitions/ar.yaml +37 -27
  6. data/definitions/au.yaml +73 -13
  7. data/definitions/{be.yaml → be_fr.yaml} +15 -15
  8. data/definitions/be_nl.yaml +65 -0
  9. data/definitions/cz.yaml +7 -4
  10. data/definitions/de.yaml +80 -10
  11. data/definitions/index.yaml +3 -2
  12. data/definitions/jp.yaml +20 -3
  13. data/definitions/nl.yaml +2 -1
  14. data/definitions/nz.yaml +0 -3
  15. data/lib/generated_definitions/MANIFEST +2 -0
  16. data/lib/generated_definitions/REGIONS.rb +1 -1
  17. data/lib/generated_definitions/ar.rb +9 -6
  18. data/lib/generated_definitions/au.rb +33 -9
  19. data/lib/generated_definitions/be_fr.rb +40 -0
  20. data/lib/generated_definitions/be_nl.rb +40 -0
  21. data/lib/generated_definitions/de.rb +14 -5
  22. data/lib/generated_definitions/europe.rb +37 -16
  23. data/lib/generated_definitions/jp.rb +3 -2
  24. data/lib/generated_definitions/nl.rb +1 -1
  25. data/lib/generated_definitions/nz.rb +0 -1
  26. data/lib/holidays.rb +12 -0
  27. data/lib/holidays/date_calculator/easter.rb +9 -9
  28. data/lib/holidays/date_calculator/weekend_modifier.rb +25 -4
  29. data/lib/holidays/definition/context/generator.rb +1 -1
  30. data/lib/holidays/definition/repository/holidays_by_month.rb +1 -1
  31. data/lib/holidays/option/context/parse_options.rb +1 -1
  32. data/lib/holidays/version.rb +1 -1
  33. data/test/defs/test_defs_ar.rb +18 -14
  34. data/test/defs/test_defs_au.rb +29 -2
  35. data/test/defs/{test_defs_be.rb → test_defs_be_fr.rb} +5 -4
  36. data/test/defs/test_defs_be_nl.rb +26 -0
  37. data/test/defs/test_defs_de.rb +25 -4
  38. data/test/defs/test_defs_europe.rb +44 -6
  39. data/test/defs/test_defs_jp.rb +8 -0
  40. data/test/holidays/date_calculator/test_weekend_modifier.rb +10 -0
  41. data/test/test_all_regions.rb +1 -1
  42. metadata +11 -6
  43. data/definitions/SYNTAX.rdoc +0 -111
@@ -36,7 +36,8 @@ module Holidays
36
36
  {:wday => 1, :week => 1, :name => "May Day", :regions => [:au_nt]},
37
37
  {:function => lambda { |year| Holidays.may_pub_hol_sa(year) }, :function_id => "may_pub_hol_sa(year)", :name => "May Public Holiday", :regions => [:au_sa]}],
38
38
  6 => [{:wday => 1, :week => 1, :name => "Foundation Day", :regions => [:au_wa]},
39
- {:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_qld, :au_tas, :au_nt, :au_vic]},
39
+ {:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_tas, :au_nt, :au_vic]},
40
+ {:function => lambda { |year| Holidays.qld_queens_birthday_june(year) }, :function_id => "qld_queens_birthday_june(year)", :name => "Queen's Birthday", :regions => [:au_qld]},
40
41
  {:mday => 6, :type => :informal, :name => "Queensland Day", :regions => [:au_qld]}],
41
42
  7 => [{:wday => 5, :week => 3, :name => "Cairns Show", :regions => [:au_qld_cairns]}],
42
43
  8 => [{:wday => 3, :week => -3, :name => "Ekka", :regions => [:au_qld_brisbane]}],
@@ -50,9 +51,12 @@ module Holidays
50
51
  11 => [{:function => lambda { |year| Holidays.g20_day_2014_only(year) }, :function_id => "g20_day_2014_only(year)", :name => "G20 Day", :regions => [:au_qld_brisbane]},
51
52
  {:wday => 1, :week => 1, :name => "Recreation Day", :regions => [:au_tas_north]},
52
53
  {:wday => 2, :week => 1, :name => "Melbourne Cup Day", :regions => [:au_vic_melbourne]}],
53
- 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:au]},
54
- {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:au_nsw, :au_vic, :au_qld, :au_act, :au_wa]},
55
- {:function => lambda { |year| Holidays.to_weekday_if_boxing_weekend_from_year(year) }, :function_id => "to_weekday_if_boxing_weekend_from_year(year)", :name => "Boxing Day", :regions => [:au_sa, :au_tas, :au_nt]}]
54
+ 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_tuesday_if_sunday_or_monday_if_saturday(date) }, :observed_id => "to_tuesday_if_sunday_or_monday_if_saturday", :name => "Christmas Day", :regions => [:au_qld, :au_nsw, :au_act, :au_tas, :au_wa]},
55
+ {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:au_sa]},
56
+ {:function => lambda { |year| Holidays.xmas_to_weekday_if_weekend(year) }, :function_id => "xmas_to_weekday_if_weekend(year)", :name => "Christmas Day", :regions => [:au_vic, :au_nt]},
57
+ {:mday => 26, :observed => lambda { |date| Holidays.to_tuesday_if_sunday_or_monday_if_saturday(date) }, :observed_id => "to_tuesday_if_sunday_or_monday_if_saturday", :name => "Boxing Day", :regions => [:au_nsw, :au_vic, :au_qld, :au_act, :au_wa]},
58
+ {:function => lambda { |year| Holidays.to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year) }, :function_id => "to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)", :name => "Boxing Day", :regions => [:au_sa]},
59
+ {:function => lambda { |year| Holidays.to_weekday_if_boxing_weekend_from_year(year) }, :function_id => "to_weekday_if_boxing_weekend_from_year(year)", :name => "Boxing Day", :regions => [:au_tas, :au_nt]}]
56
60
  }
57
61
  end
58
62
  end
@@ -66,22 +70,42 @@ end
66
70
 
67
71
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
68
72
  # celebrated twice in 2012
73
+ # in october again from 2016
69
74
  def self.qld_queens_bday_october(year)
70
- year == 2012 ? 1 : nil
75
+ if year >= 2016
76
+ Holidays.calculate_day_of_month(year, 10, 1, 1)
77
+ elsif year == 2012
78
+ 1
79
+ else
80
+ nil
81
+ end
71
82
  end
72
83
 
73
84
 
74
85
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
75
- # changed from may to october after 2012
86
+ # for 2013 to 2016 it was in October, otherwise it's in May
76
87
  def self.qld_labour_day_may(year)
77
- year <= 2012 ? Holidays.calculate_day_of_month(year, 5, 1, 1) : nil
88
+ if year < 2013 || year >= 2016
89
+ Holidays.calculate_day_of_month(year, 5, 1, 1)
90
+ end
78
91
  end
79
92
 
80
93
 
81
94
  # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
82
- # changed from may to october after 2012
95
+ # for 2013 to 2016 it was in October, otherwise it's in May
83
96
  def self.qld_labour_day_october(year)
84
- year <= 2012 ? nil : Holidays.calculate_day_of_month(year, 10, 1, 1)
97
+ if year >= 2013 && year < 2016
98
+ Holidays.calculate_day_of_month(year, 10, 1, 1)
99
+ end
100
+ end
101
+
102
+
103
+ # http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
104
+ # in june until 2015
105
+ def self.qld_queens_birthday_june(year)
106
+ if year <= 2015
107
+ Holidays.calculate_day_of_month(year, 6, 2, 1)
108
+ end
85
109
  end
86
110
 
87
111
 
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ module Holidays
3
+ # This file is generated by the Ruby Holidays gem.
4
+ #
5
+ # Definitions loaded: definitions/be_fr.yaml
6
+ #
7
+ # To use the definitions in this file, load it right after you load the
8
+ # Holiday gem:
9
+ #
10
+ # require 'holidays'
11
+ # require 'generated_definitions/be_fr'
12
+ #
13
+ # All the definitions are available at https://github.com/alexdunae/holidays
14
+ module BE_FR # :nodoc:
15
+ def self.defined_regions
16
+ [:be_fr]
17
+ end
18
+
19
+ def self.holidays_by_month
20
+ {
21
+ 0 => [{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:be_fr]},
22
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:be_fr]},
23
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:be_fr]},
24
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:be_fr]},
25
+ {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Lundi de Pentecôte", :regions => [:be_fr]}],
26
+ 1 => [{:mday => 1, :name => "Jour de l'an", :regions => [:be_fr]}],
27
+ 5 => [{:mday => 1, :name => "Fête du travail", :regions => [:be_fr]}],
28
+ 7 => [{:mday => 21, :name => "Fête nationale", :regions => [:be_fr]}],
29
+ 8 => [{:mday => 15, :name => "Assomption", :regions => [:be_fr]}],
30
+ 11 => [{:mday => 1, :name => "Toussaint", :regions => [:be_fr]},
31
+ {:mday => 11, :name => "Armistice 1918", :regions => [:be_fr]}],
32
+ 12 => [{:mday => 25, :name => "Noël", :regions => [:be_fr]}]
33
+ }
34
+ end
35
+ end
36
+
37
+
38
+ end
39
+
40
+ Holidays.merge_defs(Holidays::BE_FR.defined_regions, Holidays::BE_FR.holidays_by_month)
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ module Holidays
3
+ # This file is generated by the Ruby Holidays gem.
4
+ #
5
+ # Definitions loaded: definitions/be_nl.yaml
6
+ #
7
+ # To use the definitions in this file, load it right after you load the
8
+ # Holiday gem:
9
+ #
10
+ # require 'holidays'
11
+ # require 'generated_definitions/be_nl'
12
+ #
13
+ # All the definitions are available at https://github.com/alexdunae/holidays
14
+ module BE_NL # :nodoc:
15
+ def self.defined_regions
16
+ [:be_nl]
17
+ end
18
+
19
+ def self.holidays_by_month
20
+ {
21
+ 0 => [{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:be_nl]},
22
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Paasmaandag", :regions => [:be_nl]},
23
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "O.H. Hemelvaart", :regions => [:be_nl]},
24
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:be_nl]},
25
+ {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinkstermaandag", :regions => [:be_nl]}],
26
+ 1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:be_nl]}],
27
+ 5 => [{:mday => 1, :name => "Feest van de Arbeid", :regions => [:be_nl]}],
28
+ 7 => [{:mday => 21, :name => "Nationale Feestdag", :regions => [:be_nl]}],
29
+ 8 => [{:mday => 15, :name => "O.L.V. Hemelvaart", :regions => [:be_nl]}],
30
+ 11 => [{:mday => 1, :name => "Allerheiligen", :regions => [:be_nl]},
31
+ {:mday => 11, :name => "Wapenstilstand 1918", :regions => [:be_nl]}],
32
+ 12 => [{:mday => 25, :name => "Kerstmis", :regions => [:be_nl]}]
33
+ }
34
+ end
35
+ end
36
+
37
+
38
+ end
39
+
40
+ Holidays.merge_defs(Holidays::BE_NL.defined_regions, Holidays::BE_NL.holidays_by_month)
@@ -13,27 +13,36 @@ module Holidays
13
13
  # All the definitions are available at https://github.com/alexdunae/holidays
14
14
  module DE # :nodoc:
15
15
  def self.defined_regions
16
- [:de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_st, :de_by_aux, :de_bb, :de_mv, :de_sn, :de_th]
16
+ [:de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_aux, :de_th_aux, :de_sn, :de_st, :de_by_aux, :de_bb, :de_mv, :de_th]
17
17
  end
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
21
  0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:de]},
22
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :type => :informal, :name => "Ostersonntag", :regions => [:de]},
22
23
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:de]},
23
24
  {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:de]},
25
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :type => :informal, :name => "Pfingstsonntag", :regions => [:de]},
24
26
  {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:de]},
25
- {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl]}],
27
+ {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_aux, :de_th_aux]},
28
+ {:function => lambda { |year| Holidays.easter(year)-52 }, :function_id => "easter(year)-52", :type => :informal, :name => "Weiberfastnacht", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn]},
29
+ {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :type => :informal, :name => "Rosenmontag", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn]},
30
+ {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :type => :informal, :name => "Aschermittwoch", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn]}],
26
31
  1 => [{:mday => 1, :name => "Neujahrstag", :regions => [:de]},
27
32
  {:mday => 6, :name => "Heilige Drei Könige", :regions => [:de_bw, :de_by, :de_st]}],
28
33
  5 => [{:mday => 1, :name => "Tag der Arbeit", :regions => [:de]}],
29
34
  8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by, :de_sl]},
30
35
  {:mday => 8, :name => "Friedensfest", :regions => [:de_by_aux]}],
31
36
  10 => [{:mday => 3, :name => "Tag der Deutschen Einheit", :regions => [:de]},
32
- {:mday => 31, :name => "Reformationstag", :regions => [:de_bb, :de_mv, :de_sn, :de_st, :de_th]}],
37
+ {:mday => 31, :name => "Reformationstag", :regions => [:de_bb, :de_mv, :de_sn, :de_st, :de_th]},
38
+ {:mday => 31, :type => :informal, :name => "Reformationstag", :regions => [:de_bw]},
39
+ {:mday => 31, :year_ranges => [{:limited => [2017]}],:name => "Reformationstag", :regions => [:de]}],
33
40
  11 => [{:mday => 1, :name => "Allerheiligen", :regions => [:de_bw, :de_by, :de_nw, :de_rp, :de_sl]},
34
41
  {:function => lambda { |year| Holidays.de_buss_und_bettag(year) }, :function_id => "de_buss_und_bettag(year)", :name => "Buß- und Bettag", :regions => [:de_sn]}],
35
- 12 => [{:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]},
36
- {:mday => 26, :name => "2. Weihnachtstag", :regions => [:de]}]
42
+ 12 => [{:mday => 24, :type => :informal, :name => "Heilig Abend", :regions => [:de]},
43
+ {:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]},
44
+ {:mday => 26, :name => "2. Weihnachtstag", :regions => [:de]},
45
+ {:mday => 31, :type => :informal, :name => "Silvester", :regions => [:de]}]
37
46
  }
38
47
  end
39
48
  end
@@ -2,7 +2,7 @@
2
2
  module Holidays
3
3
  # This file is generated by the Ruby Holidays gem.
4
4
  #
5
- # Definitions loaded: definitions/at.yaml, definitions/be.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
5
+ # 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
6
6
  #
7
7
  # To use the definitions in this file, load it right after you load the
8
8
  # Holiday gem:
@@ -13,7 +13,7 @@ module Holidays
13
13
  # All the definitions are available at https://github.com/alexdunae/holidays
14
14
  module EUROPE # :nodoc:
15
15
  def self.defined_regions
16
- [:at, :be, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_st, :de_by_aux, :de_bb, :de_mv, :de_sn, :de_th, :el, :es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es, :es_ct, :es_v, :es_vc, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :ie, :is, :it, :li, :lt, :nl, :no, :pl, :pt, :ro, :sk, :si, :bg_en, :bg_bg]
16
+ [:at, :be_fr, :be_nl, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_aux, :de_th_aux, :de_sn, :de_st, :de_by_aux, :de_bb, :de_mv, :de_th, :el, :es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es, :es_ct, :es_v, :es_vc, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :ie, :is, :it, :li, :lt, :nl, :no, :pl, :pt, :ro, :sk, :si, :bg_en, :bg_bg]
17
17
  end
18
18
 
19
19
  def self.holidays_by_month
@@ -22,11 +22,16 @@ module Holidays
22
22
  {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:at]},
23
23
  {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:at]},
24
24
  {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:at]},
25
- {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:be]},
26
- {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:be]},
27
- {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:be]},
28
- {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:be]},
29
- {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Lundi de Pentecôte", :regions => [:be]},
25
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:be_fr]},
26
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:be_fr]},
27
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:be_fr]},
28
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:be_fr]},
29
+ {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Lundi de Pentecôte", :regions => [:be_fr]},
30
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:be_nl]},
31
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Paasmaandag", :regions => [:be_nl]},
32
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "O.H. Hemelvaart", :regions => [:be_nl]},
33
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:be_nl]},
34
+ {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinkstermaandag", :regions => [:be_nl]},
30
35
  {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju]},
31
36
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_vs, :ch_ge, :ch_ju]},
32
37
  {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Auffahrt", :regions => [:ch]},
@@ -46,10 +51,15 @@ module Holidays
46
51
  {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]},
47
52
  {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]},
48
53
  {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:de]},
54
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :type => :informal, :name => "Ostersonntag", :regions => [:de]},
49
55
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:de]},
50
56
  {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:de]},
57
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :type => :informal, :name => "Pfingstsonntag", :regions => [:de]},
51
58
  {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:de]},
52
- {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl]},
59
+ {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_aux, :de_th_aux]},
60
+ {:function => lambda { |year| Holidays.easter(year)-52 }, :function_id => "easter(year)-52", :type => :informal, :name => "Weiberfastnacht", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn]},
61
+ {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :type => :informal, :name => "Rosenmontag", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn]},
62
+ {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :type => :informal, :name => "Aschermittwoch", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn]},
53
63
  {:function => lambda { |year| Holidays.orthodox_easter(year)-2 }, :function_id => "orthodox_easter(year)-2", :name => "Μεγάλη Παρασκευή", :regions => [:el]},
54
64
  {:function => lambda { |year| Holidays.orthodox_easter(year)-1 }, :function_id => "orthodox_easter(year)-1", :name => "Μεγάλο Σάββατο", :regions => [:el]},
55
65
  {:function => lambda { |year| Holidays.orthodox_easter(year) }, :function_id => "orthodox_easter(year)", :name => "Κυριακή του Πάσχα", :regions => [:el]},
@@ -95,7 +105,7 @@ module Holidays
95
105
  {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:li]},
96
106
  {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Šv. Velykos", :regions => [:lt]},
97
107
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Antroji Velykų diena", :regions => [:lt]},
98
- {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]},
108
+ {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Goede Vrijdag", :regions => [:nl]},
99
109
  {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]},
100
110
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]},
101
111
  {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]},
@@ -143,7 +153,8 @@ module Holidays
143
153
  {:function => lambda { |year| Holidays.orthodox_easter_julian(year)+1 }, :function_id => "orthodox_easter_julian(year)+1", :name => "Възкресение Христово. Великден", :regions => [:bg_bg]}],
144
154
  1 => [{:mday => 1, :name => "Neujahrstag", :regions => [:at]},
145
155
  {:mday => 6, :name => "Heilige Drei Könige", :regions => [:at]},
146
- {:mday => 1, :name => "Jour de l'an", :regions => [:be]},
156
+ {:mday => 1, :name => "Jour de l'an", :regions => [:be_fr]},
157
+ {:mday => 1, :name => "Nieuwjaar", :regions => [:be_nl]},
147
158
  {:mday => 1, :name => "Neujahrstag", :regions => [:ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_vd, :ch_vs, :ch_ne, :ch_ge, :ch_ju, :ch_ti]},
148
159
  {:mday => 2, :name => "Berchtoldstag", :regions => [:ch_zh, :ch_be, :ch_lu, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_sh, :ch_sg, :ch_ag, :ch_tg, :ch_vd, :ch_vs, :ch_ne, :ch_ju]},
149
160
  {:mday => 6, :name => "Dreikönigstag", :regions => [:ch_ur, :ch_sz, :ch_ti]},
@@ -186,7 +197,8 @@ module Holidays
186
197
  {:mday => 1, :name => "New Year's Day", :regions => [:bg_en]},
187
198
  {:mday => 1, :name => "Нова година", :regions => [:bg_bg]}],
188
199
  5 => [{:mday => 1, :name => "Staatsfeiertag", :regions => [:at]},
189
- {:mday => 1, :name => "Fête du travail", :regions => [:be]},
200
+ {:mday => 1, :name => "Fête du travail", :regions => [:be_fr]},
201
+ {:mday => 1, :name => "Feest van de Arbeid", :regions => [:be_nl]},
190
202
  {:mday => 1, :name => "Tag der Arbeit", :regions => [:ch_zh, :ch_bs, :ch_bl, :ch_sh, :ch_ag, :ch_tg, :ch_ti, :ch_ne, :ch_ju]},
191
203
  {:mday => 1, :name => "Svátek práce", :regions => [:cz]},
192
204
  {:mday => 8, :name => "Den vítězství", :regions => [:cz]},
@@ -231,7 +243,8 @@ module Holidays
231
243
  {:mday => 24, :name => "Slavic Literacy Day", :regions => [:bg_en]},
232
244
  {:mday => 24, :name => "Ден на славянската писменост", :regions => [:bg_bg]}],
233
245
  8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:at]},
234
- {:mday => 15, :name => "Assomption", :regions => [:be]},
246
+ {:mday => 15, :name => "Assomption", :regions => [:be_fr]},
247
+ {:mday => 15, :name => "O.L.V. Hemelvaart", :regions => [:be_nl]},
235
248
  {:mday => 1, :name => "Bundesfeiertag", :regions => [:ch]},
236
249
  {:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_zg, :ch_fr, :ch_so, :ch_ai, :ch_ag, :ch_ti, :ch_vs, :ch_ju]},
237
250
  {:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by, :de_sl]},
@@ -259,6 +272,8 @@ module Holidays
259
272
  {:mday => 28, :name => "Den vzniku samostatného československého státu", :regions => [:cz]},
260
273
  {:mday => 3, :name => "Tag der Deutschen Einheit", :regions => [:de]},
261
274
  {:mday => 31, :name => "Reformationstag", :regions => [:de_bb, :de_mv, :de_sn, :de_st, :de_th]},
275
+ {:mday => 31, :type => :informal, :name => "Reformationstag", :regions => [:de_bw]},
276
+ {:mday => 31, :year_ranges => [{:limited => [2017]}],:name => "Reformationstag", :regions => [:de]},
262
277
  {:mday => 28, :name => "Επέτειος του Όχι", :regions => [:el]},
263
278
  {:mday => 9, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Día de Valencia", :regions => [:es_vc, :es_v]},
264
279
  {:mday => 12, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Día de la Hispanidad", :regions => [:es]},
@@ -268,8 +283,10 @@ module Holidays
268
283
  {:mday => 14, :type => :informal, :name => "Dzień Nauczyciela (Dzień Edukacji Narodowej)", :regions => [:pl]},
269
284
  {:mday => 31, :name => "dan reformacije", :regions => [:si]}],
270
285
  11 => [{:mday => 1, :name => "Allerheiligen", :regions => [:at]},
271
- {:mday => 1, :name => "Toussaint", :regions => [:be]},
272
- {:mday => 11, :name => "Armistice 1918", :regions => [:be]},
286
+ {:mday => 1, :name => "Toussaint", :regions => [:be_fr]},
287
+ {:mday => 11, :name => "Armistice 1918", :regions => [:be_fr]},
288
+ {:mday => 1, :name => "Allerheiligen", :regions => [:be_nl]},
289
+ {:mday => 11, :name => "Wapenstilstand 1918", :regions => [:be_nl]},
273
290
  {:mday => 1, :name => "Allerheiligen", :regions => [:ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_ai, :ch_sg, :ch_ag, :ch_ti, :ch_vs, :ch_ju]},
274
291
  {:mday => 17, :name => "Den boje za svobodu a demokracii", :regions => [:cz]},
275
292
  {:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]},
@@ -299,7 +316,8 @@ module Holidays
299
316
  12 => [{:mday => 8, :name => "Mariä Empfägnis", :regions => [:at]},
300
317
  {:mday => 25, :name => "1. Weihnachtstag", :regions => [:at]},
301
318
  {:mday => 26, :name => "2. Weihnachtstag", :regions => [:at]},
302
- {:mday => 25, :name => "Noël", :regions => [:be]},
319
+ {:mday => 25, :name => "Noël", :regions => [:be_fr]},
320
+ {:mday => 25, :name => "Kerstmis", :regions => [:be_nl]},
303
321
  {:mday => 8, :name => "Maria Empfängnis", :regions => [:ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_zg, :ch_fr, :ch_ai, :ch_ag, :ch_ti, :ch_vs]},
304
322
  {:mday => 25, :name => "Weihnachten", :regions => [:ch]},
305
323
  {:mday => 26, :name => "Stefanstag", :regions => [:ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vs, :ch_ne]},
@@ -311,8 +329,10 @@ module Holidays
311
329
  {:mday => 24, :type => :informal, :name => "Juleaftensdag", :regions => [:dk]},
312
330
  {:mday => 25, :name => "1. juledag", :regions => [:dk]},
313
331
  {:mday => 26, :name => "2. juledag", :regions => [:dk]},
332
+ {:mday => 24, :type => :informal, :name => "Heilig Abend", :regions => [:de]},
314
333
  {:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]},
315
334
  {:mday => 26, :name => "2. Weihnachtstag", :regions => [:de]},
335
+ {:mday => 31, :type => :informal, :name => "Silvester", :regions => [:de]},
316
336
  {:mday => 25, :name => "Χριστούγεννα", :regions => [:el]},
317
337
  {:mday => 26, :name => "Δεύτερη ημέρα των Χριστουγέννων", :regions => [:el]},
318
338
  {:mday => 6, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Día de la Constitución", :regions => [:es]},
@@ -372,7 +392,8 @@ module Holidays
372
392
  {:mday => 25, :name => "Рождество Христово. Коледа", :regions => [:bg_bg]},
373
393
  {:mday => 26, :name => "Christmas", :regions => [:bg_en]},
374
394
  {:mday => 26, :name => "Рождество Христово. Коледа", :regions => [:bg_bg]}],
375
- 7 => [{:mday => 21, :name => "Fête nationale", :regions => [:be]},
395
+ 7 => [{:mday => 21, :name => "Fête nationale", :regions => [:be_fr]},
396
+ {:mday => 21, :name => "Nationale Feestdag", :regions => [:be_nl]},
376
397
  {:mday => 5, :name => "Den slovanských věrozvěstů Cyrila a Metoděje", :regions => [:cz]},
377
398
  {:mday => 6, :name => "Den upálení mistra Jana Husa", :regions => [:cz]},
378
399
  {:mday => 23, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Santiago Apostol", :regions => [:es_ga]},
@@ -33,8 +33,9 @@ module Holidays
33
33
  {:function => lambda { |year| Holidays.jp_substitute_holiday(year, 5, 3) }, :function_id => "jp_substitute_holiday(year, 5, 3)", :name => "振替休日", :regions => [:jp]},
34
34
  {:function => lambda { |year| Holidays.jp_substitute_holiday(year, 5, 4) }, :function_id => "jp_substitute_holiday(year, 5, 4)", :name => "振替休日", :regions => [:jp]},
35
35
  {:function => lambda { |year| Holidays.jp_substitute_holiday(year, 5, 5) }, :function_id => "jp_substitute_holiday(year, 5, 5)", :name => "振替休日", :regions => [:jp]}],
36
- 7 => [{:wday => 1, :week => 3, :name => "海の日", :regions => [:jp]},
37
- {:function => lambda { |year| Holidays.jp_substitute_holiday(year, 7, Holidays.calculate_day_of_month(year, 7, 3, 1)) }, :function_id => "jp_substitute_holiday(year, 7, Holidays.calculate_day_of_month(year, 7, 3, 1))", :name => "振替休日", :regions => [:jp]}],
36
+ 7 => [{:mday => 20, :year_ranges => [{:between => 1996..2002}],:name => "海の日", :regions => [:jp]},
37
+ {:function => lambda { |year| Holidays.jp_substitute_holiday(year, 7, 20) }, :function_id => "jp_substitute_holiday(year, 7, 20)", :year_ranges => [{:between => 1996..2002}],:name => "振替休日", :regions => [:jp]},
38
+ {:wday => 1, :week => 3, :year_ranges => [{:after => 2003}],:name => "海の日", :regions => [:jp]}],
38
39
  8 => [{:function => lambda { |year| Holidays.jp_mountain_holiday(year) }, :function_id => "jp_mountain_holiday(year)", :year_ranges => [{:after => 2016}],:name => "山の日", :regions => [:jp]},
39
40
  {:function => lambda { |year| Holidays.jp_substitute_holiday(Holidays.jp_mountain_holiday(year)) }, :function_id => "jp_substitute_holiday(Holidays.jp_mountain_holiday(year))", :year_ranges => [{:after => 2016}],:name => "振替休日", :regions => [:jp]}],
40
41
  9 => [{:wday => 1, :week => 3, :name => "敬老の日", :regions => [:jp]},
@@ -18,7 +18,7 @@ module Holidays
18
18
 
19
19
  def self.holidays_by_month
20
20
  {
21
- 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]},
21
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Goede Vrijdag", :regions => [:nl]},
22
22
  {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]},
23
23
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]},
24
24
  {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]},
@@ -19,7 +19,6 @@ module Holidays
19
19
  def self.holidays_by_month
20
20
  {
21
21
  0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nz]},
22
- {:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :name => "Easter Saturday", :regions => [:nz]},
23
22
  {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:nz]}],
24
23
  1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "New Year's Day", :regions => [:nz]},
25
24
  {:mday => 2, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Day after New Year's Day", :regions => [:nz]},
data/lib/holidays.rb CHANGED
@@ -161,6 +161,18 @@ module Holidays
161
161
  DateCalculatorFactory.weekend_modifier.to_weekday_if_boxing_weekend(date)
162
162
  end
163
163
 
164
+ def to_tuesday_if_sunday_or_monday_if_saturday(year)
165
+ DateCalculatorFactory.weekend_modifier.to_tuesday_if_sunday_or_monday_if_saturday(year)
166
+ end
167
+
168
+ def xmas_to_weekday_if_weekend(year)
169
+ DateCalculatorFactory.weekend_modifier.xmas_to_weekday_if_weekend(year)
170
+ end
171
+
172
+ def to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)
173
+ DateCalculatorFactory.weekend_modifier.to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)
174
+ end
175
+
164
176
  def to_weekday_if_boxing_weekend_from_year(year)
165
177
  DateCalculatorFactory.weekend_modifier.to_weekday_if_boxing_weekend_from_year(year)
166
178
  end
@@ -48,30 +48,30 @@ module Holidays
48
48
  # Copied from https://github.com/Loyolny/when_easter
49
49
  # Graciously allowed by Michał Nierebiński (https://github.com/Loyolny)
50
50
  def calculate_easter_for(year)
51
- g = year % 19 +1
52
- s = (year -1600) / 100 - (year-1600) / 400
51
+ g = year % 19 + 1
52
+ s = (year - 1600) / 100 - (year - 1600) / 400
53
53
  l = (((year - 1400) / 100) * 8) / 25
54
54
 
55
- p_2 = (3-11*g +s -l) % 30
55
+ p_2 = (3 - 11 * g + s - l) % 30
56
56
  if p_2 == 29 || (p_2 == 28 && g > 11)
57
- p = p_2 -1
57
+ p = p_2 - 1
58
58
  else
59
- p= p_2
59
+ p = p_2
60
60
  end
61
61
 
62
62
  d= (year + year / 4 - year / 100 + year / 400) % 7
63
- d_2 = (8-d) % 7
63
+ d_2 = (8 - d) % 7
64
64
 
65
65
  p_3 = (80 + p) % 7
66
66
  x_2 = d_2 - p_3
67
67
 
68
- x = (x_2 -1) % 7 +1
68
+ x = (x_2 - 1) % 7 + 1
69
69
  e = p+x
70
70
 
71
71
  if e < 11
72
- Date.civil(year,3,e+21)
72
+ Date.civil(year,3,e + 21)
73
73
  else
74
- Date.civil(year,4,e-10)
74
+ Date.civil(year,4,e - 10)
75
75
  end
76
76
  end
77
77
 
@@ -1,5 +1,3 @@
1
- require 'date'
2
-
3
1
  module Holidays
4
2
  module DateCalculator
5
3
  class WeekendModifier
@@ -18,24 +16,47 @@ module Holidays
18
16
  date
19
17
  end
20
18
 
19
+ # if Christmas falls on a Sunday, move it to the next Tuesday (Boxing Day will go on Monday)
20
+ # if Christmas falls on a Saturday, move it to the next Monday (Boxing Day will be Sunday and potentially Tuesday)
21
+ # used as a callback function, if xmas is not observed on the 25th
22
+ def xmas_to_weekday_if_weekend(year)
23
+ to_tuesday_if_sunday_or_monday_if_saturday(Date.civil(year, 12, 25))
24
+ end
25
+
21
26
  # Move Boxing Day if it falls on a weekend, leaving room for Christmas.
22
27
  # Used as a callback function.
23
28
  def to_weekday_if_boxing_weekend(date)
24
29
  if date.wday == 6 || date.wday == 0
25
30
  date += 2
26
- elsif date.wday == 1
31
+ elsif date.wday == 1 # https://github.com/holidays/holidays/issues/27
27
32
  date += 1
28
33
  end
29
34
 
30
35
  date
31
36
  end
32
37
 
38
+ # if Christmas falls on a Saturday, move it to the next Monday (Boxing Day will be Sunday and potentially Tuesday)
39
+ # if Christmas falls on a Sunday, move it to the next Tuesday (Boxing Day will go on Monday)
40
+ #
41
+ # if Boxing Day falls on a Saturday, move it to the next Monday (Christmas will go on Friday)
42
+ # if Boxing Day falls on a Sunday, move it to the next Tuesday (Christmas will go on Saturday & Monday)
43
+ def to_tuesday_if_sunday_or_monday_if_saturday(date)
44
+ date += 2 if [0, 6].include?(date.wday)
45
+ date
46
+ end
47
+
33
48
  # Call to_weekday_if_boxing_weekend but first get date based on year
34
49
  # Used as a callback function.
35
- def to_weekday_if_boxing_weekend_from_year(year)
50
+ def to_weekday_if_boxing_weekend_from_year_or_to_tuesday_if_monday(year)
36
51
  to_weekday_if_boxing_weekend(Date.civil(year, 12, 26))
37
52
  end
38
53
 
54
+ # Call to_weekday_if_boxing_weekend but first get date based on year
55
+ # Used as a callback function.
56
+ def to_weekday_if_boxing_weekend_from_year(year)
57
+ to_tuesday_if_sunday_or_monday_if_saturday(Date.civil(year, 12, 26))
58
+ end
59
+
39
60
  # Move date to Monday if it occurs on a Sunday or to Friday if it occurs on a
40
61
  # Saturday.
41
62
  # Used as a callback function.