holidays 1.0.8 → 1.1.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 +12 -0
- data/README.md +19 -0
- data/Rakefile +1 -2
- data/data/au.yaml +81 -1
- data/data/ca.yaml +40 -3
- data/data/cr.yaml +63 -0
- data/data/federal_reserve.yaml +4 -28
- data/data/fedex.yaml +56 -0
- data/data/index.yaml +2 -0
- data/data/jp.yaml +8 -1
- data/lib/holidays.rb +219 -0
- data/lib/holidays/MANIFEST +2 -0
- data/lib/holidays/ar.rb +1 -1
- data/lib/holidays/at.rb +1 -1
- data/lib/holidays/au.rb +27 -4
- data/lib/holidays/be.rb +1 -1
- data/lib/holidays/br.rb +1 -1
- data/lib/holidays/ca.rb +6 -3
- data/lib/holidays/ch.rb +1 -1
- data/lib/holidays/cl.rb +1 -1
- data/lib/holidays/cr.rb +39 -0
- data/lib/holidays/cz.rb +1 -1
- data/lib/holidays/de.rb +2 -2
- data/lib/holidays/dk.rb +1 -1
- data/lib/holidays/ecb_target.rb +1 -1
- data/lib/holidays/el.rb +1 -1
- data/lib/holidays/es.rb +1 -1
- data/lib/holidays/europe.rb +75 -32
- data/lib/holidays/fed_ex.rb +36 -0
- data/lib/holidays/federal_reserve.rb +5 -8
- data/lib/holidays/fi.rb +1 -1
- data/lib/holidays/fr.rb +1 -1
- data/lib/holidays/gb.rb +1 -1
- data/lib/holidays/hr.rb +1 -1
- data/lib/holidays/hu.rb +1 -1
- data/lib/holidays/ie.rb +1 -1
- data/lib/holidays/is.rb +1 -1
- data/lib/holidays/it.rb +1 -1
- data/lib/holidays/jp.rb +3 -2
- data/lib/holidays/li.rb +1 -1
- data/lib/holidays/lt.rb +1 -1
- data/lib/holidays/ma.rb +1 -1
- data/lib/holidays/mx.rb +1 -1
- data/lib/holidays/nerc.rb +1 -1
- data/lib/holidays/nl.rb +1 -1
- data/lib/holidays/no.rb +1 -1
- data/lib/holidays/north_america.rb +8 -5
- data/lib/holidays/nyse.rb +1 -1
- data/lib/holidays/nz.rb +1 -1
- data/lib/holidays/pl.rb +1 -1
- data/lib/holidays/pt.rb +1 -1
- data/lib/holidays/ro.rb +1 -1
- data/lib/holidays/scandinavia.rb +18 -11
- data/lib/holidays/se.rb +1 -1
- data/lib/holidays/sg.rb +1 -1
- data/lib/holidays/si.rb +1 -1
- data/lib/holidays/sk.rb +1 -1
- data/lib/holidays/united_nations.rb +3 -3
- data/lib/holidays/ups.rb +1 -1
- data/lib/holidays/us.rb +1 -1
- data/lib/holidays/ve.rb +1 -1
- data/lib/holidays/version.rb +1 -1
- data/lib/holidays/vi.rb +1 -1
- data/lib/holidays/za.rb +1 -1
- data/test/data/test_custom_govt_holiday_defs.yaml +5 -0
- data/test/data/test_multiple_custom_holiday_defs.yaml +9 -0
- data/test/data/test_single_custom_holiday_defs.yaml +9 -0
- data/test/defs/test_defs_au.rb +32 -0
- data/test/defs/test_defs_ca.rb +25 -0
- data/test/defs/test_defs_cr.rb +22 -0
- data/test/defs/test_defs_de.rb +6 -6
- data/test/defs/test_defs_europe.rb +24 -0
- data/test/defs/test_defs_fed_ex.rb +21 -0
- data/test/defs/test_defs_federal_reserve.rb +2 -15
- data/test/defs/test_defs_jp.rb +1 -0
- data/test/defs/test_defs_north_america.rb +25 -0
- data/test/defs/test_defs_united_nations.rb +12 -0
- data/test/test_custom_holidays.rb +35 -0
- data/test/test_parse_definitions.rb +24 -0
- metadata +22 -3
- data/data/build_defs.rb +0 -157
data/data/index.yaml
CHANGED
@@ -9,6 +9,7 @@ defs:
|
|
9
9
|
CA: ['ca.yaml', 'north_america_informal.yaml']
|
10
10
|
CH: ['ch.yaml']
|
11
11
|
CL: ['cl.yaml']
|
12
|
+
CR: ['cr.yaml']
|
12
13
|
CZ: ['cz.yaml']
|
13
14
|
DK: ['dk.yaml']
|
14
15
|
DE: ['de.yaml']
|
@@ -16,6 +17,7 @@ defs:
|
|
16
17
|
EL: ['el.yaml']
|
17
18
|
ES: ['es.yaml']
|
18
19
|
Federal_Reserve: ['federal_reserve.yaml']
|
20
|
+
Fed_Ex: ['fedex.yaml']
|
19
21
|
FI: ['fi.yaml']
|
20
22
|
FR: ['fr.yaml']
|
21
23
|
GB: ['gb.yaml']
|
data/data/jp.yaml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# Japanese holiday definitions for Ruby Holiday gem.
|
2
|
-
# Reference:
|
2
|
+
# Reference:
|
3
|
+
# - http://www.h3.dion.ne.jp/~sakatsu/holiday_topic.htm
|
4
|
+
# - http://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html
|
3
5
|
#
|
4
6
|
# This definition can calculate current Japanese holidays,
|
5
7
|
# don't compat with past changes of Japan Holiday Act.
|
6
8
|
#
|
7
9
|
# CHANGES:
|
8
10
|
# 2010-12-25: Initial version by Tatsuki Sugiura <sugi@nemui.org>
|
11
|
+
# 2014-11-09: Added substitute holiday by Yoshiyuki Hirano <yoshiyuki.hirano@henteco-labs.com>
|
9
12
|
#
|
10
13
|
---
|
11
14
|
months:
|
@@ -17,6 +20,9 @@ months:
|
|
17
20
|
regions: [jp]
|
18
21
|
wday: 1
|
19
22
|
week: 2
|
23
|
+
- name: 振替休日
|
24
|
+
regions: [jp]
|
25
|
+
function: jp_substitute_holiday(year, 1, 1)
|
20
26
|
2:
|
21
27
|
- name: 建国記念日
|
22
28
|
regions: [jp]
|
@@ -176,6 +182,7 @@ tests: |
|
|
176
182
|
Date.civil(2008,12,23) => '天皇誕生日',
|
177
183
|
Date.civil(2010,3,22) => '振替休日',
|
178
184
|
Date.civil(2008,11,24) => '振替休日',
|
185
|
+
Date.civil(2012,1,2) => '振替休日',
|
179
186
|
}.each do |date, name|
|
180
187
|
assert_equal name, (Holidays.on(date, :jp, :informal)[0] || {})[:name]
|
181
188
|
end
|
data/lib/holidays.rb
CHANGED
@@ -3,6 +3,7 @@ $:.unshift File.dirname(__FILE__)
|
|
3
3
|
|
4
4
|
require 'digest/md5'
|
5
5
|
require 'date'
|
6
|
+
require 'yaml'
|
6
7
|
|
7
8
|
# == Region options
|
8
9
|
# Holidays can be defined as belonging to one or more regions and sub regions.
|
@@ -311,6 +312,20 @@ module Holidays
|
|
311
312
|
self.available(true).each { |path| require path }
|
312
313
|
end
|
313
314
|
|
315
|
+
# Parses provided holiday definition file(s) and loads them so that they are immediately available.
|
316
|
+
def self.load_custom(*files)
|
317
|
+
regions, rules_by_month, custom_methods, tests = self.parse_definition_files(files)
|
318
|
+
merge_defs(regions, rules_by_month)
|
319
|
+
end
|
320
|
+
|
321
|
+
# Parses provided holiday definition file(s) and returns strings containing the generated module and test source
|
322
|
+
def self.parse_definition_files_and_return_source(module_name, *files)
|
323
|
+
regions, rules_by_month, custom_methods, tests = self.parse_definition_files(files)
|
324
|
+
module_src, test_src = self.generate_definition_source(module_name, files, regions, rules_by_month, custom_methods, tests)
|
325
|
+
|
326
|
+
return module_src, test_src
|
327
|
+
end
|
328
|
+
|
314
329
|
private
|
315
330
|
# Returns [(arr)regions, (bool)observed, (bool)informal]
|
316
331
|
def self.parse_options(*options) # :nodoc:
|
@@ -423,6 +438,210 @@ private
|
|
423
438
|
@@proc_cache[proc_key] = function.call(year) unless @@proc_cache[proc_key]
|
424
439
|
@@proc_cache[proc_key]
|
425
440
|
end
|
441
|
+
|
442
|
+
def self.parse_definition_files(files)
|
443
|
+
raise ArgumentError, "Must have at least one file to parse" if files.empty?
|
444
|
+
|
445
|
+
all_regions = []
|
446
|
+
all_rules_by_month = {}
|
447
|
+
all_custom_methods = {}
|
448
|
+
all_tests = []
|
449
|
+
|
450
|
+
files.flatten!
|
451
|
+
|
452
|
+
files.each do |file|
|
453
|
+
definition_file = YAML.load_file(file)
|
454
|
+
|
455
|
+
regions, rules_by_month = self.parse_month_definitions(definition_file['months'])
|
456
|
+
|
457
|
+
all_regions << regions.flatten
|
458
|
+
|
459
|
+
all_rules_by_month.merge!(rules_by_month) { |month, existing, new|
|
460
|
+
existing << new
|
461
|
+
existing.flatten!
|
462
|
+
}
|
463
|
+
|
464
|
+
custom_methods = self.parse_method_definitions(definition_file['methods'])
|
465
|
+
all_custom_methods.merge!(custom_methods)
|
466
|
+
|
467
|
+
all_tests << self.parse_test_definitions(definition_file['tests'])
|
468
|
+
end
|
469
|
+
|
470
|
+
all_regions.flatten!.uniq!
|
471
|
+
|
472
|
+
[all_regions, all_rules_by_month, all_custom_methods, all_tests]
|
473
|
+
end
|
474
|
+
|
475
|
+
def self.parse_month_definitions(month_definitions)
|
476
|
+
regions = []
|
477
|
+
rules_by_month = {}
|
478
|
+
|
479
|
+
if month_definitions
|
480
|
+
month_definitions.each do |month, definitions|
|
481
|
+
rules_by_month[month] = [] unless rules_by_month[month]
|
482
|
+
definitions.each do |definition|
|
483
|
+
rule = {}
|
484
|
+
|
485
|
+
definition.each do |key, val|
|
486
|
+
rule[key.to_sym] = val
|
487
|
+
end
|
488
|
+
|
489
|
+
rule[:regions] = rule[:regions].collect { |r| r.to_sym }
|
490
|
+
|
491
|
+
regions << rule[:regions]
|
492
|
+
|
493
|
+
exists = false
|
494
|
+
rules_by_month[month].each do |ex|
|
495
|
+
if ex[:name] == rule[:name] and ex[:wday] == rule[:wday] and ex[:mday] == rule[:mday] and ex[:week] == rule[:week] and ex[:type] == rule[:type] and ex[:function] == rule[:function] and ex[:observed] == rule[:observed]
|
496
|
+
ex[:regions] << rule[:regions].flatten
|
497
|
+
exists = true
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
unless exists
|
502
|
+
rules_by_month[month] << rule
|
503
|
+
end
|
504
|
+
end
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
[regions, rules_by_month]
|
509
|
+
end
|
510
|
+
|
511
|
+
def self.parse_method_definitions(methods)
|
512
|
+
custom_methods = {}
|
513
|
+
|
514
|
+
if methods
|
515
|
+
methods.each do |name, code|
|
516
|
+
custom_methods[name] = code
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
custom_methods
|
521
|
+
end
|
522
|
+
|
523
|
+
def self.parse_test_definitions(tests)
|
524
|
+
test_strings = []
|
525
|
+
|
526
|
+
if tests
|
527
|
+
test_strings << tests
|
528
|
+
end
|
529
|
+
|
530
|
+
test_strings
|
531
|
+
end
|
532
|
+
|
533
|
+
def self.generate_definition_source(module_name, files, regions, rules_by_month, custom_methods, tests)
|
534
|
+
month_strings = self.generate_month_definition_strings(rules_by_month)
|
535
|
+
|
536
|
+
# Build the custom methods string
|
537
|
+
custom_method_string = ''
|
538
|
+
custom_methods.each do |key, code|
|
539
|
+
custom_method_string << code + "\n\n"
|
540
|
+
end
|
541
|
+
|
542
|
+
module_src = self.generate_module_src(module_name, files, regions, month_strings, custom_method_string)
|
543
|
+
test_src = self.generate_test_src(module_name, files, tests)
|
544
|
+
|
545
|
+
return module_src, test_src || ''
|
546
|
+
end
|
547
|
+
|
548
|
+
def self.generate_month_definition_strings(rules_by_month)
|
549
|
+
month_strings = []
|
550
|
+
|
551
|
+
rules_by_month.each do |month, rules|
|
552
|
+
month_string = " #{month.to_s} => ["
|
553
|
+
rule_strings = []
|
554
|
+
rules.each do |rule|
|
555
|
+
string = '{'
|
556
|
+
if rule[:mday]
|
557
|
+
string << ":mday => #{rule[:mday]}, "
|
558
|
+
elsif rule[:function]
|
559
|
+
string << ":function => lambda { |year| Holidays.#{rule[:function]} }, "
|
560
|
+
string << ":function_id => \"#{rule[:function].to_s}\", "
|
561
|
+
else
|
562
|
+
string << ":wday => #{rule[:wday]}, :week => #{rule[:week]}, "
|
563
|
+
end
|
564
|
+
|
565
|
+
if rule[:observed]
|
566
|
+
string << ":observed => lambda { |date| Holidays.#{rule[:observed]}(date) }, "
|
567
|
+
string << ":observed_id => \"#{rule[:observed].to_s}\", "
|
568
|
+
end
|
569
|
+
|
570
|
+
if rule[:type]
|
571
|
+
string << ":type => :#{rule[:type]}, "
|
572
|
+
end
|
573
|
+
|
574
|
+
# shouldn't allow the same region twice
|
575
|
+
string << ":name => \"#{rule[:name]}\", :regions => [:" + rule[:regions].uniq.join(', :') + "]}"
|
576
|
+
rule_strings << string
|
577
|
+
end
|
578
|
+
month_string << rule_strings.join(",\n ") + "]"
|
579
|
+
month_strings << month_string
|
580
|
+
end
|
581
|
+
|
582
|
+
return month_strings
|
583
|
+
end
|
584
|
+
|
585
|
+
def self.generate_module_src(module_name, files, regions, month_strings, custom_methods)
|
586
|
+
module_src = ""
|
587
|
+
|
588
|
+
module_src =<<-EOM
|
589
|
+
# encoding: utf-8
|
590
|
+
module Holidays
|
591
|
+
# This file is generated by the Ruby Holidays gem.
|
592
|
+
#
|
593
|
+
# Definitions loaded: #{files.join(', ')}
|
594
|
+
#
|
595
|
+
# To use the definitions in this file, load it right after you load the
|
596
|
+
# Holiday gem:
|
597
|
+
#
|
598
|
+
# require 'holidays'
|
599
|
+
# require 'holidays/#{module_name.to_s.downcase}'
|
600
|
+
#
|
601
|
+
# All the definitions are available at https://github.com/alexdunae/holidays
|
602
|
+
module #{module_name.to_s.upcase} # :nodoc:
|
603
|
+
def self.defined_regions
|
604
|
+
[:#{regions.join(', :')}]
|
605
|
+
end
|
606
|
+
|
607
|
+
def self.holidays_by_month
|
608
|
+
{
|
609
|
+
#{month_strings.join(",\n")}
|
610
|
+
}
|
611
|
+
end
|
612
|
+
end
|
613
|
+
|
614
|
+
#{custom_methods}
|
615
|
+
end
|
616
|
+
|
617
|
+
Holidays.merge_defs(Holidays::#{module_name.to_s.upcase}.defined_regions, Holidays::#{module_name.to_s.upcase}.holidays_by_month)
|
618
|
+
EOM
|
619
|
+
|
620
|
+
return module_src
|
621
|
+
end
|
622
|
+
|
623
|
+
def self.generate_test_src(module_name, files, tests)
|
624
|
+
unless tests.empty?
|
625
|
+
test_src = ""
|
626
|
+
|
627
|
+
test_src =<<-EndOfTests
|
628
|
+
# encoding: utf-8
|
629
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
630
|
+
|
631
|
+
# This file is generated by the Ruby Holiday gem.
|
632
|
+
#
|
633
|
+
# Definitions loaded: #{files.join(', ')}
|
634
|
+
class #{module_name.to_s.capitalize}DefinitionTests < Test::Unit::TestCase # :nodoc:
|
635
|
+
|
636
|
+
def test_#{module_name.to_s.downcase}
|
637
|
+
#{tests.join("\n\n")}
|
638
|
+
end
|
639
|
+
end
|
640
|
+
EndOfTests
|
641
|
+
end
|
642
|
+
|
643
|
+
return test_src
|
644
|
+
end
|
426
645
|
end
|
427
646
|
|
428
647
|
# === Extending Ruby's Date class with the Holidays gem
|
data/lib/holidays/MANIFEST
CHANGED
@@ -9,6 +9,7 @@ The following definition files are included in this installation:
|
|
9
9
|
* holidays/ca
|
10
10
|
* holidays/ch
|
11
11
|
* holidays/cl
|
12
|
+
* holidays/cr
|
12
13
|
* holidays/cz
|
13
14
|
* holidays/de
|
14
15
|
* holidays/dk
|
@@ -16,6 +17,7 @@ The following definition files are included in this installation:
|
|
16
17
|
* holidays/el
|
17
18
|
* holidays/es
|
18
19
|
* holidays/europe
|
20
|
+
* holidays/fed_ex
|
19
21
|
* holidays/federal_reserve
|
20
22
|
* holidays/fi
|
21
23
|
* holidays/fr
|
data/lib/holidays/ar.rb
CHANGED
data/lib/holidays/at.rb
CHANGED
data/lib/holidays/au.rb
CHANGED
@@ -4,7 +4,7 @@ module Holidays
|
|
4
4
|
#
|
5
5
|
# Definitions loaded: data/au.yaml
|
6
6
|
#
|
7
|
-
# To use the definitions in this file, load it right after you load the
|
7
|
+
# To use the definitions in this file, load it right after you load the
|
8
8
|
# Holiday gem:
|
9
9
|
#
|
10
10
|
# require 'holidays'
|
@@ -13,18 +13,19 @@ module Holidays
|
|
13
13
|
# All the definitions are available at https://github.com/alexdunae/holidays
|
14
14
|
module AU # :nodoc:
|
15
15
|
def self.defined_regions
|
16
|
-
[:au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_qld_brisbane, :au_tas, :au_wa]
|
16
|
+
[:au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_qld_brisbane, :au_qld_cairns, :au_tas, :au_tas_south, :au_wa, :au_tas_north]
|
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 => "Good Friday", :regions => [:au]},
|
22
|
-
{:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :name => "Easter Saturday", :regions => [:au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_qld_brisbane]},
|
22
|
+
{:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :name => "Easter Saturday", :regions => [:au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_qld_brisbane, :au_qld_cairns]},
|
23
23
|
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Easter Sunday", :regions => [:au_nsw]},
|
24
24
|
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:au]},
|
25
25
|
{:function => lambda { |year| Holidays.easter(year)+2 }, :function_id => "easter(year)+2", :name => "Easter Monday", :regions => [:au_tas]}],
|
26
26
|
1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "New Year's Day", :regions => [:au]},
|
27
27
|
{:mday => 26, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Australia Day", :regions => [:au]}],
|
28
|
+
2 => [{:wday => 1, :week => 2, :name => "Royal Hobart Regatta", :regions => [:au_tas_south]}],
|
28
29
|
3 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_wa]},
|
29
30
|
{:wday => 1, :week => 2, :name => "Eight Hours Day", :regions => [:au_tas]},
|
30
31
|
{:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic]}],
|
@@ -34,10 +35,17 @@ module Holidays
|
|
34
35
|
6 => [{:wday => 1, :week => 1, :name => "Foundation Day", :regions => [:au_wa]},
|
35
36
|
{:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_qld, :au_tas, :au_nt, :au_vic]},
|
36
37
|
{:mday => 6, :type => :informal, :name => "Queensland Day", :regions => [:au_qld]}],
|
38
|
+
7 => [{:wday => 5, :week => 3, :name => "Cairns Show", :regions => [:au_qld_cairns]}],
|
37
39
|
8 => [{:wday => 3, :week => -3, :name => "Ekka", :regions => [:au_qld_brisbane]}],
|
40
|
+
9 => [{:wday => 1, :week => -1, :name => "Queen's Birthday", :regions => [:au_wa]},
|
41
|
+
{:wday => 1, :week => -1, :name => "Family & Community Day", :regions => [:au_act]}],
|
38
42
|
10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]},
|
39
43
|
{:function => lambda { |year| Holidays.qld_labour_day_october(year) }, :function_id => "qld_labour_day_october(year)", :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Labour Day", :regions => [:au_qld]},
|
40
|
-
{:function => lambda { |year| Holidays.qld_queens_bday_october(year) }, :function_id => "qld_queens_bday_october(year)", :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Queen's Birthday", :regions => [:au_qld]}
|
44
|
+
{:function => lambda { |year| Holidays.qld_queens_bday_october(year) }, :function_id => "qld_queens_bday_october(year)", :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Queen's Birthday", :regions => [:au_qld]},
|
45
|
+
{:function => lambda { |year| Holidays.hobart_show_day(year) }, :function_id => "hobart_show_day(year)", :name => "Royal Hobart Show", :regions => [:au_tas_south]}],
|
46
|
+
11 => [{:function => lambda { |year| Holidays.g20_day_2014_only(year) }, :function_id => "g20_day_2014_only(year)", :name => "G20 Day", :regions => [:au_qld_brisbane]},
|
47
|
+
{:wday => 1, :week => 1, :name => "Recreation Day", :regions => [:au_tas_north]},
|
48
|
+
{:wday => 2, :week => 1, :name => "Melbourne Cup Day", :regions => [:au_vic]}],
|
41
49
|
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:au]},
|
42
50
|
{:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:au]}]
|
43
51
|
}
|
@@ -65,6 +73,21 @@ def self.qld_labour_day_october(year)
|
|
65
73
|
end
|
66
74
|
|
67
75
|
|
76
|
+
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
|
77
|
+
# G20 day in brisbane, in 2014, on november 14
|
78
|
+
def self.g20_day_2014_only(year)
|
79
|
+
year == 2014 ? 14 : nil
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# http://worksafe.tas.gov.au/__data/assets/pdf_file/0008/287036/Public_Holidays_2014.pdf
|
84
|
+
# The Thursday before the fourth Saturday in October.
|
85
|
+
def self.hobart_show_day(year)
|
86
|
+
fourth_sat_in_oct = Date.civil(year, 10, Date.calculate_mday(year, 10, 4, :saturday))
|
87
|
+
fourth_sat_in_oct - 2 # the thursday before
|
88
|
+
end
|
89
|
+
|
90
|
+
|
68
91
|
|
69
92
|
end
|
70
93
|
|
data/lib/holidays/be.rb
CHANGED
data/lib/holidays/br.rb
CHANGED
data/lib/holidays/ca.rb
CHANGED
@@ -4,7 +4,7 @@ module Holidays
|
|
4
4
|
#
|
5
5
|
# Definitions loaded: data/ca.yaml, data/north_america_informal.yaml
|
6
6
|
#
|
7
|
-
# To use the definitions in this file, load it right after you load the
|
7
|
+
# To use the definitions in this file, load it right after you load the
|
8
8
|
# Holiday gem:
|
9
9
|
#
|
10
10
|
# require 'holidays'
|
@@ -13,7 +13,7 @@ module Holidays
|
|
13
13
|
# All the definitions are available at https://github.com/alexdunae/holidays
|
14
14
|
module CA # :nodoc:
|
15
15
|
def self.defined_regions
|
16
|
-
[:ca, :ca_qc, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_bc, :ca_nf, :ca_nt, :ca_nu, :
|
16
|
+
[:ca, :ca_qc, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_ns, :ca_pe, :ca_bc, :ca_nf, :ca_nt, :ca_nu, :ca_nb, :ca_yk, :us]
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.holidays_by_month
|
@@ -25,6 +25,8 @@ module Holidays
|
|
25
25
|
{:mday => 2, :name => "New Year's", :regions => [:ca_qc]}],
|
26
26
|
2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
|
27
27
|
{:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
|
28
|
+
{:wday => 1, :week => 3, :name => "Nova Scotia Heritage Day", :regions => [:ca_ns]},
|
29
|
+
{:wday => 1, :week => 3, :name => "Islander Day", :regions => [:ca_pe]},
|
28
30
|
{:wday => 1, :week => 2, :name => "BC Family Day", :regions => [:ca_bc]},
|
29
31
|
{:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
30
32
|
{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
|
@@ -45,7 +47,8 @@ module Holidays
|
|
45
47
|
{:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
|
46
48
|
{:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
|
47
49
|
{:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
|
48
|
-
{:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
|
50
|
+
{:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on, :ca_nt, :ca_nu, :ca_pe]},
|
51
|
+
{:wday => 1, :week => 1, :name => "New Brunswick Day", :regions => [:ca_nb]},
|
49
52
|
{:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
|
50
53
|
9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]}],
|
51
54
|
10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
|