holidays 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +22 -8
- data/Rakefile +26 -8
- data/bin/console +7 -0
- data/bin/setup +5 -0
- data/{data → definitions}/SYNTAX.rdoc +0 -0
- data/{data → definitions}/ar.yaml +0 -0
- data/{data → definitions}/at.yaml +1 -1
- data/{data → definitions}/au.yaml +80 -51
- data/{data → definitions}/be.yaml +0 -0
- data/{data → definitions}/br.yaml +0 -0
- data/{data → definitions}/ca.yaml +0 -0
- data/{data → definitions}/ch.yaml +0 -0
- data/{data → definitions}/cl.yaml +0 -0
- data/{data → definitions}/cr.yaml +0 -0
- data/{data → definitions}/cz.yaml +0 -0
- data/{data → definitions}/de.yaml +25 -34
- data/{data → definitions}/dk.yaml +0 -0
- data/{data → definitions}/ecb_target.yaml +2 -2
- data/{data → definitions}/el.yaml +0 -0
- data/{data → definitions}/es.yaml +37 -26
- data/{data → definitions}/federal_reserve.yaml +0 -0
- data/{data → definitions}/fedex.yaml +9 -3
- data/{data → definitions}/fi.yaml +0 -0
- data/{data → definitions}/fr.yaml +0 -0
- data/{data → definitions}/gb.yaml +19 -19
- data/{data → definitions}/hr.yaml +0 -0
- data/{data → definitions}/hu.yaml +1 -1
- data/{data → definitions}/ie.yaml +0 -0
- data/{data → definitions}/index.yaml +0 -0
- data/{data → definitions}/is.yaml +0 -0
- data/{data → definitions}/it.yaml +0 -0
- data/{data → definitions}/jp.yaml +3 -3
- data/{data → definitions}/li.yaml +3 -3
- data/{data → definitions}/lt.yaml +0 -0
- data/{data → definitions}/ma.yaml +0 -0
- data/{data → definitions}/mx.yaml +0 -0
- data/{data → definitions}/nerc.yaml +0 -0
- data/{data → definitions}/nl.yaml +0 -0
- data/{data → definitions}/no.yaml +0 -0
- data/{data → definitions}/north_america_informal.yaml +0 -0
- data/{data → definitions}/nyse.yaml +0 -0
- data/{data → definitions}/nz.yaml +21 -10
- data/{data → definitions}/ph.yaml +0 -0
- data/{data → definitions}/pl.yaml +0 -0
- data/{data → definitions}/pt.yaml +0 -0
- data/{data → definitions}/ro.yaml +1 -2
- data/{data → definitions}/se.yaml +0 -0
- data/{data → definitions}/sg.yaml +0 -0
- data/{data → definitions}/si.yaml +6 -6
- data/{data → definitions}/sk.yaml +0 -0
- data/{data → definitions}/united_nations.yaml +0 -0
- data/{data → definitions}/ups.yaml +17 -11
- data/{data → definitions}/us.yaml +20 -15
- data/{data → definitions}/ve.yaml +0 -0
- data/{data → definitions}/vi.yaml +0 -0
- data/{data → definitions}/za.yaml +0 -0
- data/holidays.gemspec +2 -1
- data/lib/generated_definitions/MANIFEST +56 -0
- data/lib/generated_definitions/REGIONS.rb +4 -0
- data/lib/{holidays → generated_definitions}/ar.rb +2 -2
- data/lib/{holidays → generated_definitions}/at.rb +2 -2
- data/lib/{holidays → generated_definitions}/au.rb +19 -10
- data/lib/{holidays → generated_definitions}/be.rb +2 -2
- data/lib/{holidays → generated_definitions}/br.rb +2 -2
- data/lib/{holidays → generated_definitions}/ca.rb +2 -2
- data/lib/{holidays → generated_definitions}/ch.rb +2 -2
- data/lib/{holidays → generated_definitions}/cl.rb +2 -2
- data/lib/{holidays → generated_definitions}/cr.rb +2 -2
- data/lib/{holidays → generated_definitions}/cz.rb +2 -2
- data/lib/{holidays → generated_definitions}/de.rb +5 -4
- data/lib/{holidays → generated_definitions}/dk.rb +2 -2
- data/lib/{holidays → generated_definitions}/ecb_target.rb +2 -2
- data/lib/{holidays → generated_definitions}/el.rb +2 -2
- data/lib/{holidays → generated_definitions}/es.rb +6 -6
- data/lib/{holidays → generated_definitions}/europe.rb +7 -6
- data/lib/{holidays → generated_definitions}/fed_ex.rb +8 -3
- data/lib/{holidays → generated_definitions}/federal_reserve.rb +2 -2
- data/lib/{holidays → generated_definitions}/fi.rb +2 -2
- data/lib/{holidays → generated_definitions}/fr.rb +2 -2
- data/lib/{holidays → generated_definitions}/gb.rb +2 -2
- data/lib/{holidays → generated_definitions}/hr.rb +2 -2
- data/lib/{holidays → generated_definitions}/hu.rb +2 -2
- data/lib/{holidays → generated_definitions}/ie.rb +2 -2
- data/lib/{holidays → generated_definitions}/is.rb +2 -2
- data/lib/{holidays → generated_definitions}/it.rb +2 -2
- data/lib/{holidays → generated_definitions}/jp.rb +5 -5
- data/lib/{holidays → generated_definitions}/li.rb +2 -2
- data/lib/{holidays → generated_definitions}/lt.rb +2 -2
- data/lib/{holidays → generated_definitions}/ma.rb +2 -2
- data/lib/{holidays → generated_definitions}/mx.rb +2 -2
- data/lib/{holidays → generated_definitions}/nerc.rb +2 -2
- data/lib/{holidays → generated_definitions}/nl.rb +2 -2
- data/lib/{holidays → generated_definitions}/no.rb +2 -2
- data/lib/{holidays → generated_definitions}/north_america.rb +8 -3
- data/lib/{holidays → generated_definitions}/nyse.rb +2 -2
- data/lib/{holidays → generated_definitions}/nz.rb +5 -5
- data/lib/{holidays → generated_definitions}/ph.rb +2 -2
- data/lib/{holidays → generated_definitions}/pl.rb +2 -2
- data/lib/{holidays → generated_definitions}/pt.rb +2 -2
- data/lib/{holidays → generated_definitions}/ro.rb +2 -2
- data/lib/{holidays → generated_definitions}/scandinavia.rb +2 -2
- data/lib/{holidays → generated_definitions}/se.rb +2 -2
- data/lib/{holidays → generated_definitions}/sg.rb +2 -2
- data/lib/{holidays → generated_definitions}/si.rb +2 -2
- data/lib/{holidays → generated_definitions}/sk.rb +2 -2
- data/lib/{holidays → generated_definitions}/united_nations.rb +2 -2
- data/lib/{holidays → generated_definitions}/ups.rb +8 -3
- data/lib/{holidays → generated_definitions}/us.rb +8 -3
- data/lib/{holidays → generated_definitions}/ve.rb +2 -2
- data/lib/{holidays → generated_definitions}/vi.rb +2 -2
- data/lib/{holidays → generated_definitions}/za.rb +2 -2
- data/lib/holidays.rb +120 -665
- data/lib/holidays/core_extensions/date.rb +39 -0
- data/lib/holidays/date_calculator/day_of_month.rb +68 -0
- data/lib/holidays/date_calculator/easter.rb +58 -0
- data/lib/holidays/date_calculator/weekend_modifier.rb +49 -0
- data/lib/holidays/date_calculator_factory.rb +21 -0
- data/lib/holidays/definition/context/generator.rb +216 -0
- data/lib/holidays/definition/context/merger.rb +26 -0
- data/lib/holidays/definition/repository/cache.rb +33 -0
- data/lib/holidays/definition/repository/holidays_by_month.rb +49 -0
- data/lib/holidays/definition/repository/proc_cache.rb +36 -0
- data/lib/holidays/definition/repository/regions.rb +36 -0
- data/lib/holidays/definition/validator/region.rb +45 -0
- data/lib/holidays/definition_factory.rb +50 -0
- data/lib/holidays/option/context/parse_options.rb +96 -0
- data/lib/holidays/option_factory.rb +14 -0
- data/lib/holidays/use_case/context/between.rb +105 -0
- data/lib/holidays/use_case/context/dates_driver_builder.rb +64 -0
- data/lib/holidays/use_case_factory.rb +20 -0
- data/lib/holidays/version.rb +1 -1
- data/test/defs/test_defs_ar.rb +1 -1
- data/test/defs/test_defs_at.rb +2 -2
- data/test/defs/test_defs_au.rb +61 -43
- data/test/defs/test_defs_be.rb +1 -1
- data/test/defs/test_defs_br.rb +1 -1
- data/test/defs/test_defs_ca.rb +1 -1
- data/test/defs/test_defs_ch.rb +1 -1
- data/test/defs/test_defs_cl.rb +1 -1
- data/test/defs/test_defs_cr.rb +1 -1
- data/test/defs/test_defs_cz.rb +1 -1
- data/test/defs/test_defs_de.rb +18 -30
- data/test/defs/test_defs_dk.rb +1 -1
- data/test/defs/test_defs_ecb_target.rb +3 -3
- data/test/defs/test_defs_el.rb +1 -1
- data/test/defs/test_defs_es.rb +36 -25
- data/test/defs/test_defs_europe.rb +82 -84
- data/test/defs/test_defs_fed_ex.rb +4 -1
- data/test/defs/test_defs_federal_reserve.rb +1 -1
- data/test/defs/test_defs_fi.rb +1 -1
- data/test/defs/test_defs_fr.rb +1 -1
- data/test/defs/test_defs_gb.rb +20 -20
- data/test/defs/test_defs_hr.rb +1 -1
- data/test/defs/test_defs_hu.rb +2 -2
- data/test/defs/test_defs_ie.rb +1 -1
- data/test/defs/test_defs_is.rb +1 -1
- data/test/defs/test_defs_it.rb +1 -1
- data/test/defs/test_defs_jp.rb +1 -1
- data/test/defs/test_defs_li.rb +4 -4
- data/test/defs/test_defs_lt.rb +1 -1
- data/test/defs/test_defs_ma.rb +1 -1
- data/test/defs/test_defs_mx.rb +1 -1
- data/test/defs/test_defs_nerc.rb +1 -1
- data/test/defs/test_defs_nl.rb +1 -1
- data/test/defs/test_defs_no.rb +1 -1
- data/test/defs/test_defs_north_america.rb +5 -3
- data/test/defs/test_defs_nyse.rb +1 -1
- data/test/defs/test_defs_nz.rb +19 -9
- data/test/defs/test_defs_ph.rb +1 -1
- data/test/defs/test_defs_pl.rb +1 -1
- data/test/defs/test_defs_pt.rb +1 -1
- data/test/defs/test_defs_ro.rb +2 -3
- data/test/defs/test_defs_scandinavia.rb +1 -1
- data/test/defs/test_defs_se.rb +1 -1
- data/test/defs/test_defs_sg.rb +1 -1
- data/test/defs/test_defs_si.rb +7 -7
- data/test/defs/test_defs_sk.rb +1 -1
- data/test/defs/test_defs_united_nations.rb +1 -1
- data/test/defs/test_defs_ups.rb +5 -2
- data/test/defs/test_defs_us.rb +5 -3
- data/test/defs/test_defs_ve.rb +1 -1
- data/test/defs/test_defs_vi.rb +1 -1
- data/test/defs/test_defs_za.rb +1 -1
- data/test/{test_date.rb → holidays/core_extensions/test_date.rb} +8 -2
- data/test/holidays/date_calculator/test_day_of_month.rb +27 -0
- data/test/holidays/date_calculator/test_easter.rb +29 -0
- data/test/holidays/date_calculator/test_weekend_modifier.rb +33 -0
- data/test/holidays/definition/context/test_generator.rb +84 -0
- data/test/holidays/definition/context/test_merger.rb +22 -0
- data/test/holidays/definition/repository/test_cache.rb +82 -0
- data/test/holidays/definition/repository/test_holidays_by_month.rb +187 -0
- data/test/holidays/definition/repository/test_proc_cache.rb +29 -0
- data/test/holidays/definition/repository/test_regions.rb +86 -0
- data/test/holidays/definition/validator/test_region.rb +50 -0
- data/test/holidays/option/context/test_parse_options.rb +69 -0
- data/test/holidays/test_date_calculator_factory.rb +21 -0
- data/test/holidays/test_definition_factory.rb +34 -0
- data/test/holidays/test_option_factory.rb +9 -0
- data/test/holidays/test_use_case_factory.rb +13 -0
- data/test/holidays/use_case/context/test_between.rb +75 -0
- data/test/holidays/use_case/context/test_dates_driver_builder.rb +91 -0
- data/test/test_all_regions.rb +14 -3
- data/test/test_helper.rb +2 -1
- data/test/test_holidays.rb +19 -24
- data/test/test_holidays_between.rb +85 -0
- data/test/test_multiple_regions.rb +2 -2
- data/test/test_parse_definitions.rb +10 -4
- metadata +181 -111
- data/.coveralls.yml +0 -1
- data/lib/holidays/MANIFEST +0 -55
@@ -0,0 +1,64 @@
|
|
1
|
+
# This context builds a hash that contains {:year => [<array of months>]}. The idea is that
|
2
|
+
# we will iterate over each year and then over each month internally and check to see if the
|
3
|
+
# supplied dates match any holidays for the region and date. So if we supply start_date of 2015/1/1
|
4
|
+
# and end_date of 2015/6/1 then we will return a date driver of {:2015 => [0, 1, 2, 5, 6, 7]}.
|
5
|
+
# In the logic in the 'between' use case we will iterate over this and compare dates in these
|
6
|
+
# months to the supplied range to determine whether they should be returned to the user.
|
7
|
+
module Holidays
|
8
|
+
module UseCase
|
9
|
+
module Context
|
10
|
+
class DatesDriverBuilder
|
11
|
+
def call(start_date, end_date)
|
12
|
+
dates_driver = {}
|
13
|
+
|
14
|
+
(start_date..end_date).each do |current_date|
|
15
|
+
dates_driver[current_date.year] = [] unless dates_driver[current_date.year]
|
16
|
+
dates_driver[current_date.year] << current_date.month
|
17
|
+
|
18
|
+
dates_driver = add_border_months(current_date, dates_driver)
|
19
|
+
end
|
20
|
+
|
21
|
+
clean(dates_driver)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# As part of https://github.com/holidays/holidays/issues/146 I am returning
|
27
|
+
# additional months in an attempt to catch month-spanning date situations (i.e.
|
28
|
+
# dates falling on 2/1 but being observed on 1/31). By including the additional months
|
29
|
+
# we are increasing runtimes slightly but improving accuracy, which is more important
|
30
|
+
# to me at this stage.
|
31
|
+
def add_border_months(current_date, dates_driver)
|
32
|
+
if current_date.month == 1
|
33
|
+
dates_driver[current_date.year] << 2
|
34
|
+
|
35
|
+
prev_year = current_date.year - 1
|
36
|
+
dates_driver[prev_year] = [] unless dates_driver[prev_year]
|
37
|
+
dates_driver[prev_year] << 12
|
38
|
+
elsif current_date.month == 12
|
39
|
+
dates_driver[current_date.year] << 11
|
40
|
+
|
41
|
+
next_year = current_date.year + 1
|
42
|
+
dates_driver[next_year] = [] unless dates_driver[next_year]
|
43
|
+
dates_driver[next_year] << 1
|
44
|
+
else
|
45
|
+
dates_driver[current_date.year] << current_date.month - 1 << current_date.month + 1
|
46
|
+
end
|
47
|
+
|
48
|
+
dates_driver
|
49
|
+
end
|
50
|
+
|
51
|
+
def clean(dates_driver)
|
52
|
+
dates_driver.each do |year, months|
|
53
|
+
dates_driver[year] << 0 # Always add variable month '0' for proc calc purposes
|
54
|
+
|
55
|
+
dates_driver[year].uniq!
|
56
|
+
dates_driver[year].sort!
|
57
|
+
end
|
58
|
+
|
59
|
+
dates_driver
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'holidays/use_case/context/between'
|
2
|
+
require 'holidays/use_case/context/dates_driver_builder'
|
3
|
+
|
4
|
+
module Holidays
|
5
|
+
class UseCaseFactory
|
6
|
+
class << self
|
7
|
+
def between
|
8
|
+
UseCase::Context::Between.new(
|
9
|
+
DefinitionFactory.holidays_by_month_repository,
|
10
|
+
DateCalculatorFactory.day_of_month_calculator,
|
11
|
+
DefinitionFactory.proc_cache_repository,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def dates_driver_builder
|
16
|
+
UseCase::Context::DatesDriverBuilder.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/holidays/version.rb
CHANGED
data/test/defs/test_defs_ar.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/ar.yaml
|
7
7
|
class ArDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_ar
|
data/test/defs/test_defs_at.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/at.yaml
|
7
7
|
class AtDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_at
|
@@ -18,7 +18,7 @@ class AtDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
18
18
|
assert_equal name, (Holidays.on(date, :at, :informal)[0] || {})[:name]
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
assert_equal [], Holidays.on(Date.civil(2010,5,8), :at), '2010-05-08 is not a holiday in Austria'
|
22
22
|
|
23
23
|
end
|
24
24
|
end
|
data/test/defs/test_defs_au.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/au.yaml
|
7
7
|
class AuDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_au
|
@@ -12,71 +12,67 @@ class AuDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
12
12
|
Date.civil(2007,4,6) => 'Good Friday',
|
13
13
|
Date.civil(2007,4,9) => 'Easter Monday',
|
14
14
|
Date.civil(2007,4,25) => 'ANZAC Day',
|
15
|
-
Date.civil(2007,12,25) => 'Christmas Day',
|
16
|
-
Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
|
15
|
+
Date.civil(2007,12,25) => 'Christmas Day'}.each do |date, name|
|
17
16
|
assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name]
|
18
17
|
end
|
19
18
|
|
20
19
|
[:au_sa, :au_act, :au_nsw, :au_].each do |r|
|
21
|
-
assert_equal 'Labour Day', Date.civil(2007,10,1)
|
20
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2007,10,1), r)[0][:name]
|
22
21
|
end
|
23
22
|
|
24
23
|
[:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
|
25
|
-
assert_equal 'Queen\'s Birthday', Date.civil(2007,6,11)
|
24
|
+
assert_equal 'Queen\'s Birthday', Holidays.on(Date.civil(2007,6,11), r)[0][:name]
|
26
25
|
end
|
27
26
|
|
28
|
-
assert_equal 'Labour Day', Date.civil(2007,3,5)
|
29
|
-
assert_equal 'Labour Day', Date.civil(2007,3,12)
|
30
|
-
assert_equal 'Labour Day', Date.civil(2007,5,7)
|
27
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2007,3,5), :au_wa)[0][:name]
|
28
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2007,3,12), :au_vic)[0][:name]
|
29
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2007,5,7), :au_qld)[0][:name]
|
31
30
|
|
32
|
-
assert_equal 'Easter Sunday', Date.civil(2007,4,8)
|
31
|
+
assert_equal 'Easter Sunday', Holidays.on(Date.civil(2007,4,8), :au_nsw)[0][:name]
|
33
32
|
|
34
|
-
assert_equal 'May Day', Date.civil(2007,5,7)
|
33
|
+
assert_equal 'May Day', Holidays.on(Date.civil(2007,5,7), :au_nt)[0][:name]
|
35
34
|
|
36
|
-
assert_equal 'Eight Hours Day', Date.civil(2007,3,12)
|
35
|
+
assert_equal 'Eight Hours Day', Holidays.on(Date.civil(2007,3,12), :au_tas)[0][:name]
|
37
36
|
|
38
|
-
assert_equal 'Labour Day', Date.civil(2013,10,7)
|
39
|
-
assert_equal 'Labour Day', Date.civil(2012,5,7)
|
37
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2013,10,7), :au_qld)[0][:name]
|
38
|
+
assert_equal 'Labour Day', Holidays.on(Date.civil(2012,5,7), :au_qld)[0][:name]
|
40
39
|
|
41
|
-
assert_equal "Queen's Birthday", Date.civil(2012,6,11)
|
42
|
-
assert_equal "Queen's Birthday", Date.civil(2012,10,1)
|
43
|
-
assert_equal "Queen's Birthday", Date.civil(2013,6,10)
|
40
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,6,11), :au_qld)[0][:name]
|
41
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2012,10,1), :au_qld)[0][:name]
|
42
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2013,6,10), :au_qld)[0][:name]
|
44
43
|
|
45
|
-
assert_equal "Queen's Birthday", Date.civil(2014, 9, 29)
|
46
|
-
assert_equal "Queen's Birthday", Date.civil(2015, 9, 28)
|
47
|
-
assert_equal "Queen's Birthday", Date.civil(2016, 9, 26)
|
44
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2014, 9, 29), :au_wa)[0][:name]
|
45
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2015, 9, 28), :au_wa)[0][:name]
|
46
|
+
assert_equal "Queen's Birthday", Holidays.on(Date.civil(2016, 9, 26), :au_wa)[0][:name]
|
48
47
|
|
49
|
-
assert_equal "Family & Community Day", Date.civil(2014, 9, 29)
|
50
|
-
assert_equal "Family & Community Day", Date.civil(2015, 9, 28)
|
51
|
-
assert_equal "Family & Community Day", Date.civil(2016, 9, 26)
|
48
|
+
assert_equal "Family & Community Day", Holidays.on(Date.civil(2014, 9, 29), :au_act)[0][:name]
|
49
|
+
assert_equal "Family & Community Day", Holidays.on(Date.civil(2015, 9, 28), :au_act)[0][:name]
|
50
|
+
assert_equal "Family & Community Day", Holidays.on(Date.civil(2016, 9, 26), :au_act)[0][:name]
|
52
51
|
|
53
|
-
assert_equal 'Australia Day', Date.civil(2014,1,26)
|
54
|
-
assert_equal 'Australia Day', Date.civil(2014,1,27)
|
52
|
+
assert_equal 'Australia Day', Holidays.on(Date.civil(2014,1,26), :au_qld)[0][:name]
|
53
|
+
assert_equal 'Australia Day', Holidays.on(Date.civil(2014,1,27), :au_qld, :observed)[0][:name]
|
55
54
|
|
56
|
-
assert_equal 'Cairns Show', Date.civil(2014,7,18)
|
57
|
-
assert_equal 'Cairns Show', Date.civil(2013,7,19)
|
55
|
+
assert_equal 'Cairns Show', Holidays.on(Date.civil(2014,7,18), :au_qld_cairns)[0][:name]
|
56
|
+
assert_equal 'Cairns Show', Holidays.on(Date.civil(2013,7,19), :au_qld_cairns)[0][:name]
|
58
57
|
|
59
|
-
assert_equal 'Royal Hobart Show', Date.civil(2013, 10, 24)
|
60
|
-
assert_equal 'Royal Hobart Show', Date.civil(2014, 10, 23)
|
61
|
-
assert_equal 'Royal Hobart Show', Date.civil(2015, 10, 22)
|
62
|
-
assert_equal 'Royal Hobart Show', Date.civil(2016, 10, 20)
|
58
|
+
assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2013, 10, 24), :au_tas_south)[0][:name]
|
59
|
+
assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2014, 10, 23), :au_tas_south)[0][:name]
|
60
|
+
assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2015, 10, 22), :au_tas_south)[0][:name]
|
61
|
+
assert_equal 'Royal Hobart Show', Holidays.on(Date.civil(2016, 10, 20), :au_tas_south)[0][:name]
|
63
62
|
|
64
|
-
assert_equal 'Recreation Day', Date.civil(2013, 11, 4)
|
65
|
-
assert_equal 'Recreation Day', Date.civil(2014, 11, 3)
|
66
|
-
assert_equal 'Recreation Day', Date.civil(2015, 11, 2)
|
67
|
-
assert_equal 'Recreation Day', Date.civil(2016, 11, 7)
|
63
|
+
assert_equal 'Recreation Day', Holidays.on(Date.civil(2013, 11, 4), :au_tas_north)[0][:name]
|
64
|
+
assert_equal 'Recreation Day', Holidays.on(Date.civil(2014, 11, 3), :au_tas_north)[0][:name]
|
65
|
+
assert_equal 'Recreation Day', Holidays.on(Date.civil(2015, 11, 2), :au_tas_north)[0][:name]
|
66
|
+
assert_equal 'Recreation Day', Holidays.on(Date.civil(2016, 11, 7), :au_tas_north)[0][:name]
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
assert_equal [], Date.civil(2015,11,14).holidays(:au_qld_brisbane)
|
68
|
+
assert_nil Date.civil(2014,11,4).holidays(:au_vic)[0]
|
69
|
+
assert_nil Date.civil(2015,11,3).holidays(:au_vic)[0]
|
72
70
|
|
73
|
-
assert_equal 'Melbourne Cup Day', Date.civil(2014,11,4)
|
74
|
-
assert_equal 'Melbourne Cup Day', Date.civil(2015,11,3)
|
71
|
+
assert_equal 'Melbourne Cup Day', Holidays.on(Date.civil(2014,11,4), :au_vic_melbourne)[0][:name]
|
72
|
+
assert_equal 'Melbourne Cup Day', Holidays.on(Date.civil(2015,11,3), :au_vic_melbourne)[0][:name]
|
75
73
|
|
76
|
-
assert_equal '
|
77
|
-
|
78
|
-
assert_equal 'Royal Hobart Regatta', Date.civil(2015, 2, 9).holidays(:au_tas_south)[0][:name]
|
79
|
-
assert_equal 'Royal Hobart Regatta', Date.civil(2016, 2, 8).holidays(:au_tas_south)[0][:name]
|
74
|
+
assert_equal 'Friday before the AFL Grand Final', Date.civil(2015,10,2).holidays(:au_vic)[0][:name]
|
75
|
+
assert_nil Date.civil(2016,10,2).holidays(:au_vic)[0]
|
80
76
|
|
81
77
|
assert_equal "May Public Holiday", Date.civil(2005, 5, 16).holidays(:au_sa)[0][:name]
|
82
78
|
assert_equal [], Date.civil(2014, 5, 19).holidays(:au_sa)
|
@@ -91,5 +87,27 @@ assert_equal "ANZAC Day", Date.civil(2015, 4, 25).holidays(:au_qld)[0][:name]
|
|
91
87
|
assert_equal "ANZAC Day", Date.civil(2015, 4, 25).holidays(:au_wa)[0][:name]
|
92
88
|
assert_equal [], Date.civil(2015, 4, 27).holidays(:au_qld, :observed)
|
93
89
|
assert_equal "ANZAC Day", Date.civil(2015, 4, 27).holidays(:au_wa, :observed)[0][:name]
|
90
|
+
|
91
|
+
# BOXING DAY - QLD observes weekend and monday
|
92
|
+
assert_equal "Boxing Day", Date.civil(2015, 12, 26).holidays(:au_qld)[0][:name]
|
93
|
+
assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_qld, :observed)[0][:name]
|
94
|
+
|
95
|
+
# BOXING DAY - SA gets monday only. same for TAS and NT.
|
96
|
+
assert_nil Date.civil(2015, 12, 26).holidays(:au_sa)[0]
|
97
|
+
assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_sa)[0][:name]
|
98
|
+
assert_nil Date.civil(2015, 12, 26).holidays(:au_tas)[0]
|
99
|
+
assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_tas)[0][:name]
|
100
|
+
assert_nil Date.civil(2015, 12, 26).holidays(:au_nt)[0]
|
101
|
+
assert_equal "Boxing Day", Date.civil(2015, 12, 28).holidays(:au_nt)[0][:name]
|
102
|
+
|
103
|
+
assert_equal 'G20 Day', Holidays.on(Date.civil(2014,11,14), :au_qld_brisbane)[0][:name]
|
104
|
+
assert_equal [], Holidays.on(Date.civil(2014,11,14), :au_qld)
|
105
|
+
assert_equal [], Holidays.on(Date.civil(2015,11,14), :au_qld_brisbane)
|
106
|
+
|
107
|
+
assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2012, 2, 13), :au_tas_south)[0][:name]
|
108
|
+
assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2014, 2, 10), :au_tas_south)[0][:name]
|
109
|
+
assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2015, 2, 9), :au_tas_south)[0][:name]
|
110
|
+
assert_equal 'Royal Hobart Regatta', Holidays.on(Date.civil(2016, 2, 8), :au_tas_south)[0][:name]
|
111
|
+
|
94
112
|
end
|
95
113
|
end
|
data/test/defs/test_defs_be.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/be.yaml
|
7
7
|
class BeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_be
|
data/test/defs/test_defs_br.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/br.yaml
|
7
7
|
class BrDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_br
|
data/test/defs/test_defs_ca.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/ca.yaml, definitions/north_america_informal.yaml
|
7
7
|
class CaDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_ca
|
data/test/defs/test_defs_ch.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/ch.yaml
|
7
7
|
class ChDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_ch
|
data/test/defs/test_defs_cl.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/cl.yaml
|
7
7
|
class ClDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_cl
|
data/test/defs/test_defs_cr.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/cr.yaml
|
7
7
|
class CrDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_cr
|
data/test/defs/test_defs_cz.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/cz.yaml
|
7
7
|
class CzDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_cz
|
data/test/defs/test_defs_de.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/de.yaml
|
7
7
|
class DeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_de
|
@@ -20,56 +20,44 @@ class DeDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
20
20
|
end
|
21
21
|
|
22
22
|
[:de_bw, :de_by, :de_st, :de_].each do |r|
|
23
|
-
assert_equal 'Heilige Drei Könige', Date.civil(2009,1,6)
|
23
|
+
assert_equal 'Heilige Drei Könige', Holidays.on(Date.civil(2009,1,6), r)[0][:name]
|
24
24
|
end
|
25
25
|
|
26
26
|
[:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
27
|
-
assert_equal 'Fronleichnam', Date.civil(2009,6,11)
|
27
|
+
assert_equal 'Fronleichnam', Holidays.on(Date.civil(2009,6,11), r)[0][:name]
|
28
28
|
end
|
29
29
|
|
30
30
|
[:de_by, :de_sl, :de_].each do |r|
|
31
|
-
assert_equal 'Mariä Himmelfahrt', Date.civil(2009,8,15)
|
31
|
+
assert_equal 'Mariä Himmelfahrt', Holidays.on(Date.civil(2009,8,15), r)[0][:name]
|
32
32
|
end
|
33
33
|
|
34
34
|
[:de_bb, :de_mv, :de_sn, :de_st, :de_th, :de_].each do |r|
|
35
|
-
assert_equal 'Reformationstag', Date.civil(2009,10,31)
|
35
|
+
assert_equal 'Reformationstag', Holidays.on(Date.civil(2009,10,31), r)[0][:name]
|
36
36
|
end
|
37
37
|
|
38
38
|
[:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
39
|
-
assert_equal 'Allerheiligen', Date.civil(2009,11,1)
|
39
|
+
assert_equal 'Allerheiligen', Holidays.on(Date.civil(2009,11,1), r)[0][:name]
|
40
40
|
end
|
41
41
|
|
42
|
-
[:
|
43
|
-
assert_equal '
|
42
|
+
[:de_by_aux].each do |r|
|
43
|
+
assert_equal 'Friedensfest', Date.civil(2015,8,8).holidays(r)[0][:name]
|
44
44
|
end
|
45
45
|
|
46
|
-
[:
|
47
|
-
|
46
|
+
[:de,
|
47
|
+
:de_bw, :de_by, :de_bb, :de_he, :de_mv,
|
48
|
+
:de_nw, :de_rp, :de_sl, :de_sn, :de_st, :de_th].each do |r|
|
49
|
+
assert_equal [], Holidays.on(Date.civil(2015,8,8), r), "Friedensfest is not a holiday in #{r}"
|
48
50
|
end
|
49
51
|
|
50
|
-
[
|
51
|
-
assert !Date.civil(2009,6,11).holiday?(r), "Fronleichnam is not a holiday in #{r}"
|
52
|
-
end
|
53
|
-
|
54
|
-
[:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
|
55
|
-
assert !Date.civil(2009,8,15).holiday?(r), "Mariä Himmelfahrt is not a holiday in #{r}"
|
56
|
-
end
|
57
|
-
|
58
|
-
[:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
|
59
|
-
assert !Date.civil(2009,10,31).holiday?(r), 'Reformationstag is not a holiday in #{r}'
|
60
|
-
end
|
61
|
-
|
62
|
-
[:de_be, :de_hb, :de_hh, :de_ni, :de_sh].each do |r|
|
63
|
-
assert !Date.civil(2009,11,1).holiday?(r), "Allerheiligen is not a holiday in #{r}"
|
64
|
-
end
|
52
|
+
assert_equal [], Holidays.on(Date.civil(2010,5,8), :de), '2010-05-08 is not a holiday in Germany'
|
65
53
|
|
66
|
-
|
54
|
+
assert_equal [], Holidays.on(Date.civil(2010,8,8), :de), '2010-08-08 is not a holiday in Germany'
|
67
55
|
|
68
56
|
# Repentance Day
|
69
|
-
assert_equal 'Buß- und Bettag', Date.civil(2004,11,17)
|
70
|
-
assert_equal 'Buß- und Bettag', Date.civil(2005,11,16)
|
71
|
-
assert_equal 'Buß- und Bettag', Date.civil(2006,11,22)
|
72
|
-
assert_equal 'Buß- und Bettag', Date.civil(2009,11,18)
|
57
|
+
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2004,11,17), :de_sn)[0][:name]
|
58
|
+
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2005,11,16), :de_sn)[0][:name]
|
59
|
+
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2006,11,22), :de_sn)[0][:name]
|
60
|
+
assert_equal 'Buß- und Bettag', Holidays.on(Date.civil(2009,11,18), :de_sn)[0][:name]
|
73
61
|
|
74
62
|
end
|
75
63
|
end
|
data/test/defs/test_defs_dk.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/dk.yaml
|
7
7
|
class DkDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_dk
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
|
3
3
|
|
4
4
|
# This file is generated by the Ruby Holiday gem.
|
5
5
|
#
|
6
|
-
# Definitions loaded:
|
6
|
+
# Definitions loaded: definitions/ecb_target.yaml
|
7
7
|
class Ecb_targetDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
8
|
|
9
9
|
def test_ecb_target
|
@@ -16,8 +16,8 @@ class Ecb_targetDefinitionTests < Test::Unit::TestCase # :nodoc:
|
|
16
16
|
assert_equal name, (Holidays.on(date, :ecb_target)[0] || {})[:name]
|
17
17
|
end
|
18
18
|
|
19
|
-
assert_equal 'Good Friday', Date.civil(2013,3,29)
|
20
|
-
assert_equal 'Easter Monday', Date.civil(2013,4,1)
|
19
|
+
assert_equal 'Good Friday', Holidays.on(Date.civil(2013,3,29), :ecb_target)[0][:name]
|
20
|
+
assert_equal 'Easter Monday', Holidays.on(Date.civil(2013,4,1), :ecb_target)[0][:name]
|
21
21
|
|
22
22
|
end
|
23
23
|
end
|