holidays 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/data/index.yaml +2 -0
- data/data/nyse.yaml +63 -0
- data/data/ups.yaml +56 -0
- data/lib/holidays/MANIFEST +2 -0
- data/lib/holidays/nyse.rb +32 -0
- data/lib/holidays/ups.rb +31 -0
- data/rakefile.rb +3 -3
- data/test/defs/test_defs_nyse.rb +22 -0
- data/test/defs/test_defs_ups.rb +21 -0
- metadata +8 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= Ruby Holidays Gem CHANGELOG
|
2
2
|
|
3
|
+
== 0.9.3
|
4
|
+
* Added New York Stock Exchange holidays (thank you Alan Larkin).
|
5
|
+
* Added UPS holidays (thank you Tim Anglade).
|
6
|
+
* Fixed rakefile to force lower case definition file names.
|
7
|
+
|
3
8
|
== 0.9.2
|
4
9
|
* Included rakefile in Gem (thank you James Herdman).
|
5
10
|
|
data/data/index.yaml
CHANGED
@@ -13,9 +13,11 @@ defs:
|
|
13
13
|
IT: ['it.yaml']
|
14
14
|
MX: ['mx.yaml', 'north_america_informal.yaml']
|
15
15
|
NL: ['nl.yaml']
|
16
|
+
NYSE: ['nyse.yaml']
|
16
17
|
PT: ['se.yaml']
|
17
18
|
US: ['us.yaml', 'north_america_informal.yaml']
|
18
19
|
United_Nations: ['united_nations.yaml']
|
20
|
+
UPS: ['ups.yaml']
|
19
21
|
ZA: ['za.yaml']
|
20
22
|
North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml']
|
21
23
|
Europe: ['dk.yaml', 'de.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'nl.yaml', 'pt.yaml']
|
data/data/nyse.yaml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# NYSE holiday definitions for the Ruby Holiday gem.
|
2
|
+
#
|
3
|
+
# By Alan Larkin
|
4
|
+
# Source: http://www.nyse.com/about/newsevents/1176373643795.html#earlyclose2008
|
5
|
+
#
|
6
|
+
# Updated 2008-11-19.
|
7
|
+
---
|
8
|
+
months:
|
9
|
+
0:
|
10
|
+
- name: Good Friday
|
11
|
+
regions: [nyse]
|
12
|
+
function: easter(year)-2
|
13
|
+
1:
|
14
|
+
- name: New Year's Day
|
15
|
+
regions: [nyse]
|
16
|
+
mday: 1
|
17
|
+
- name: Martin Luther King, Jr. Day
|
18
|
+
week: 3
|
19
|
+
regions: [nyse]
|
20
|
+
wday: 1
|
21
|
+
2:
|
22
|
+
- name: Presidents' Day
|
23
|
+
week: 3
|
24
|
+
regions: [nyse]
|
25
|
+
wday: 1
|
26
|
+
5:
|
27
|
+
- name: Memorial Day
|
28
|
+
week: -1
|
29
|
+
regions: [nyse]
|
30
|
+
wday: 1
|
31
|
+
7:
|
32
|
+
- name: Independence Day
|
33
|
+
regions: [nyse]
|
34
|
+
mday: 4
|
35
|
+
observed: to_weekday_if_weekend
|
36
|
+
9:
|
37
|
+
- name: Labor Day
|
38
|
+
week: 1
|
39
|
+
regions: [nyse]
|
40
|
+
wday: 1
|
41
|
+
11:
|
42
|
+
- name: Thanksgiving
|
43
|
+
week: 4
|
44
|
+
regions: [nyse]
|
45
|
+
wday: 4
|
46
|
+
12:
|
47
|
+
- name: Christmas Day
|
48
|
+
regions: [nyse]
|
49
|
+
mday: 25
|
50
|
+
observed: to_weekday_if_weekend
|
51
|
+
methods:
|
52
|
+
tests: |
|
53
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
54
|
+
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
55
|
+
Date.civil(2008,2,18) => 'Presidents\' Day',
|
56
|
+
Date.civil(2008,3,21) => 'Good Friday',
|
57
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
58
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
59
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
60
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
61
|
+
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
62
|
+
assert_equal name, Holidays.on(date, :nyse)[0][:name]
|
63
|
+
end
|
data/data/ups.yaml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# UPS holiday definitions for the Ruby Holiday gem.
|
2
|
+
#
|
3
|
+
# By Tim Anglade
|
4
|
+
#
|
5
|
+
# Updated: 2008-09-23.
|
6
|
+
# Source: http://www.ups.com/content/us/en/resources/ship/imp_exp/operation.html
|
7
|
+
---
|
8
|
+
months:
|
9
|
+
1:
|
10
|
+
- name: New Year's Day
|
11
|
+
regions: [ups]
|
12
|
+
mday: 1
|
13
|
+
observed: to_weekday_if_weekend
|
14
|
+
5:
|
15
|
+
- name: Memorial Day
|
16
|
+
week: -1
|
17
|
+
regions: [ups]
|
18
|
+
wday: 1
|
19
|
+
7:
|
20
|
+
- name: Independence Day
|
21
|
+
regions: [ups]
|
22
|
+
mday: 4
|
23
|
+
observed: to_weekday_if_weekend
|
24
|
+
9:
|
25
|
+
- name: Labor Day
|
26
|
+
week: 1
|
27
|
+
regions: [ups]
|
28
|
+
wday: 1
|
29
|
+
11:
|
30
|
+
- name: Thanksgiving
|
31
|
+
week: 4
|
32
|
+
regions: [ups]
|
33
|
+
wday: 4
|
34
|
+
- name: Day After Thanksgiving
|
35
|
+
week: 4
|
36
|
+
regions: [ups]
|
37
|
+
wday: 5
|
38
|
+
12:
|
39
|
+
- name: Christmas Day
|
40
|
+
regions: [ups]
|
41
|
+
mday: 25
|
42
|
+
observed: to_weekday_if_weekend
|
43
|
+
- name: New Year's Eve
|
44
|
+
regions: [ups]
|
45
|
+
mday: 31
|
46
|
+
tests: |
|
47
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
48
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
49
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
50
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
51
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
52
|
+
Date.civil(2008,11,28) => 'Day After Thanksgiving',
|
53
|
+
Date.civil(2008,12,25) => 'Christmas Day',
|
54
|
+
Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
|
55
|
+
assert_equal name, Holidays.on(date, :ups)[0][:name]
|
56
|
+
end
|
data/lib/holidays/MANIFEST
CHANGED
@@ -15,9 +15,11 @@ The following definition files are included in this installation:
|
|
15
15
|
* holidays/mx
|
16
16
|
* holidays/nl
|
17
17
|
* holidays/north_america
|
18
|
+
* holidays/nyse
|
18
19
|
* holidays/pt
|
19
20
|
* holidays/scandinavia
|
20
21
|
* holidays/se
|
21
22
|
* holidays/united_nations
|
23
|
+
* holidays/ups
|
22
24
|
* holidays/us
|
23
25
|
* holidays/za
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Holidays
|
2
|
+
# This file is generated by the Ruby Holiday gem.
|
3
|
+
#
|
4
|
+
# Definitions loaded: data/nyse.yaml
|
5
|
+
#
|
6
|
+
# To use the definitions in this file, load them right after you load the
|
7
|
+
# Holiday gem:
|
8
|
+
#
|
9
|
+
# require 'holidays'
|
10
|
+
# require 'holidays/nyse'
|
11
|
+
#
|
12
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
13
|
+
module NYSE # :nodoc:
|
14
|
+
DEFINED_REGIONS = [:nyse]
|
15
|
+
|
16
|
+
HOLIDAYS_BY_MONTH = {
|
17
|
+
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:nyse]}],
|
18
|
+
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}],
|
19
|
+
11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:nyse]}],
|
20
|
+
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:nyse]},
|
21
|
+
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:nyse]}],
|
22
|
+
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:nyse]}],
|
23
|
+
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:nyse]}],
|
24
|
+
2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:nyse]}],
|
25
|
+
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:nyse]}]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
Holidays.merge_defs(Holidays::NYSE::DEFINED_REGIONS, Holidays::NYSE::HOLIDAYS_BY_MONTH)
|
data/lib/holidays/ups.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Holidays
|
2
|
+
# This file is generated by the Ruby Holiday gem.
|
3
|
+
#
|
4
|
+
# Definitions loaded: data/ups.yaml
|
5
|
+
#
|
6
|
+
# To use the definitions in this file, load them right after you load the
|
7
|
+
# Holiday gem:
|
8
|
+
#
|
9
|
+
# require 'holidays'
|
10
|
+
# require 'holidays/ups'
|
11
|
+
#
|
12
|
+
# More definitions are available at http://code.dunae.ca/holidays.
|
13
|
+
module UPS # :nodoc:
|
14
|
+
DEFINED_REGIONS = [:ups]
|
15
|
+
|
16
|
+
HOLIDAYS_BY_MONTH = {
|
17
|
+
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:ups]}],
|
18
|
+
11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:ups]},
|
19
|
+
{:wday => 5, :week => 4, :name => "Day After Thanksgiving", :regions => [:ups]}],
|
20
|
+
1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:ups]}],
|
21
|
+
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:ups]},
|
22
|
+
{:mday => 31, :name => "New Year's Eve", :regions => [:ups]}],
|
23
|
+
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:ups]}],
|
24
|
+
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:ups]}]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
Holidays.merge_defs(Holidays::UPS::DEFINED_REGIONS, Holidays::UPS::HOLIDAYS_BY_MONTH)
|
data/rakefile.rb
CHANGED
@@ -46,7 +46,7 @@ end
|
|
46
46
|
|
47
47
|
spec = Gem::Specification.new do |s|
|
48
48
|
s.name = 'holidays'
|
49
|
-
s.version = '0.9.
|
49
|
+
s.version = '0.9.3'
|
50
50
|
s.author = 'Alex Dunae'
|
51
51
|
s.homepage = 'http://code.dunae.ca/holidays'
|
52
52
|
s.platform = Gem::Platform::RUBY
|
@@ -85,11 +85,11 @@ namespace :defs do
|
|
85
85
|
files.uniq!
|
86
86
|
|
87
87
|
module_src, test_src = parse_holiday_defs(region, files)
|
88
|
-
File.open("lib/holidays/#{region.to_s}.rb","w") do |file|
|
88
|
+
File.open("lib/holidays/#{region.downcase.to_s}.rb","w") do |file|
|
89
89
|
file.puts module_src
|
90
90
|
end
|
91
91
|
unless test_src.empty?
|
92
|
-
File.open("test/defs/test_defs_#{region.to_s}.rb","w") do |file|
|
92
|
+
File.open("test/defs/test_defs_#{region.downcase.to_s}.rb","w") do |file|
|
93
93
|
file.puts test_src
|
94
94
|
end
|
95
95
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require 'holidays/nyse'
|
3
|
+
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
5
|
+
#
|
6
|
+
# Definitions loaded: data/nyse.yaml
|
7
|
+
class NyseDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
|
+
|
9
|
+
def test_nyse
|
10
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
11
|
+
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
12
|
+
Date.civil(2008,2,18) => 'Presidents\' Day',
|
13
|
+
Date.civil(2008,3,21) => 'Good Friday',
|
14
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
15
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
16
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
17
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
18
|
+
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
19
|
+
assert_equal name, Holidays.on(date, :nyse)[0][:name]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require 'holidays/ups'
|
3
|
+
|
4
|
+
# This file is generated by the Ruby Holiday gem.
|
5
|
+
#
|
6
|
+
# Definitions loaded: data/ups.yaml
|
7
|
+
class UpsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
8
|
+
|
9
|
+
def test_ups
|
10
|
+
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
11
|
+
Date.civil(2008,5,26) => 'Memorial Day',
|
12
|
+
Date.civil(2008,7,4) => 'Independence Day',
|
13
|
+
Date.civil(2008,9,1) => 'Labor Day',
|
14
|
+
Date.civil(2008,11,27) => 'Thanksgiving',
|
15
|
+
Date.civil(2008,11,28) => 'Day After Thanksgiving',
|
16
|
+
Date.civil(2008,12,25) => 'Christmas Day',
|
17
|
+
Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
|
18
|
+
assert_equal name, Holidays.on(date, :ups)[0][:name]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: holidays
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.9.3
|
7
|
+
date: 2008-11-19 00:00:00 -08:00
|
8
8
|
summary: A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -45,10 +45,12 @@ files:
|
|
45
45
|
- lib/holidays/mx.rb
|
46
46
|
- lib/holidays/nl.rb
|
47
47
|
- lib/holidays/north_america.rb
|
48
|
+
- lib/holidays/nyse.rb
|
48
49
|
- lib/holidays/pt.rb
|
49
50
|
- lib/holidays/scandinavia.rb
|
50
51
|
- lib/holidays/se.rb
|
51
52
|
- lib/holidays/united_nations.rb
|
53
|
+
- lib/holidays/ups.rb
|
52
54
|
- lib/holidays/us.rb
|
53
55
|
- lib/holidays/za.rb
|
54
56
|
- lib/holidays.rb
|
@@ -67,10 +69,12 @@ files:
|
|
67
69
|
- data/mx.yaml
|
68
70
|
- data/nl.yaml
|
69
71
|
- data/north_america_informal.yaml
|
72
|
+
- data/nyse.yaml
|
70
73
|
- data/pt.yaml
|
71
74
|
- data/se.yaml
|
72
75
|
- data/SYNTAX
|
73
76
|
- data/united_nations.yaml
|
77
|
+
- data/ups.yaml
|
74
78
|
- data/us.yaml
|
75
79
|
- data/za.yaml
|
76
80
|
- rakefile.rb
|
@@ -93,9 +97,11 @@ test_files:
|
|
93
97
|
- test/defs/test_defs_mx.rb
|
94
98
|
- test/defs/test_defs_nl.rb
|
95
99
|
- test/defs/test_defs_north_america.rb
|
100
|
+
- test/defs/test_defs_nyse.rb
|
96
101
|
- test/defs/test_defs_pt.rb
|
97
102
|
- test/defs/test_defs_scandinavia.rb
|
98
103
|
- test/defs/test_defs_se.rb
|
104
|
+
- test/defs/test_defs_ups.rb
|
99
105
|
- test/defs/test_defs_us.rb
|
100
106
|
- test/defs/test_defs_za.rb
|
101
107
|
rdoc_options:
|