Added UPS and NYSE defs
This commit is contained in:
parent
429abc9a6c
commit
faaf8e8593
10 changed files with 229 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
== 0.9.3
|
||||
* Added New York Stock Exchange holidays (thank you Alan Larkin).
|
||||
* Added UPS holidays (thank you Tim Anglade).
|
||||
* Fixed rakefile to force lower case definition file names.
|
||||
|
||||
== 0.9.2
|
||||
|
|
|
@ -17,6 +17,7 @@ defs:
|
|||
PT: ['se.yaml']
|
||||
US: ['us.yaml', 'north_america_informal.yaml']
|
||||
United_Nations: ['united_nations.yaml']
|
||||
UPS: ['ups.yaml']
|
||||
ZA: ['za.yaml']
|
||||
North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml']
|
||||
Europe: ['dk.yaml', 'de.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'nl.yaml', 'pt.yaml']
|
||||
|
|
63
data/nyse.yaml
Normal file
63
data/nyse.yaml
Normal file
|
@ -0,0 +1,63 @@
|
|||
# NYSE holiday definitions for the Ruby Holiday gem.
|
||||
#
|
||||
# By Alan Larkin
|
||||
# Source: http://www.nyse.com/about/newsevents/1176373643795.html#earlyclose2008
|
||||
#
|
||||
# Updated 2008-11-19.
|
||||
---
|
||||
months:
|
||||
0:
|
||||
- name: Good Friday
|
||||
regions: [nyse]
|
||||
function: easter(year)-2
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [nyse]
|
||||
mday: 1
|
||||
- name: Martin Luther King, Jr. Day
|
||||
week: 3
|
||||
regions: [nyse]
|
||||
wday: 1
|
||||
2:
|
||||
- name: Presidents' Day
|
||||
week: 3
|
||||
regions: [nyse]
|
||||
wday: 1
|
||||
5:
|
||||
- name: Memorial Day
|
||||
week: -1
|
||||
regions: [nyse]
|
||||
wday: 1
|
||||
7:
|
||||
- name: Independence Day
|
||||
regions: [nyse]
|
||||
mday: 4
|
||||
observed: to_weekday_if_weekend
|
||||
9:
|
||||
- name: Labor Day
|
||||
week: 1
|
||||
regions: [nyse]
|
||||
wday: 1
|
||||
11:
|
||||
- name: Thanksgiving
|
||||
week: 4
|
||||
regions: [nyse]
|
||||
wday: 4
|
||||
12:
|
||||
- name: Christmas Day
|
||||
regions: [nyse]
|
||||
mday: 25
|
||||
observed: to_weekday_if_weekend
|
||||
methods:
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
||||
Date.civil(2008,2,18) => 'Presidents\' Day',
|
||||
Date.civil(2008,3,21) => 'Good Friday',
|
||||
Date.civil(2008,5,26) => 'Memorial Day',
|
||||
Date.civil(2008,7,4) => 'Independence Day',
|
||||
Date.civil(2008,9,1) => 'Labor Day',
|
||||
Date.civil(2008,11,27) => 'Thanksgiving',
|
||||
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :nyse)[0][:name]
|
||||
end
|
56
data/ups.yaml
Normal file
56
data/ups.yaml
Normal file
|
@ -0,0 +1,56 @@
|
|||
# UPS holiday definitions for the Ruby Holiday gem.
|
||||
#
|
||||
# By Tim Anglade
|
||||
#
|
||||
# Updated: 2008-09-23.
|
||||
# Source: http://www.ups.com/content/us/en/resources/ship/imp_exp/operation.html
|
||||
---
|
||||
months:
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [ups]
|
||||
mday: 1
|
||||
observed: to_weekday_if_weekend
|
||||
5:
|
||||
- name: Memorial Day
|
||||
week: -1
|
||||
regions: [ups]
|
||||
wday: 1
|
||||
7:
|
||||
- name: Independence Day
|
||||
regions: [ups]
|
||||
mday: 4
|
||||
observed: to_weekday_if_weekend
|
||||
9:
|
||||
- name: Labor Day
|
||||
week: 1
|
||||
regions: [ups]
|
||||
wday: 1
|
||||
11:
|
||||
- name: Thanksgiving
|
||||
week: 4
|
||||
regions: [ups]
|
||||
wday: 4
|
||||
- name: Day After Thanksgiving
|
||||
week: 4
|
||||
regions: [ups]
|
||||
wday: 5
|
||||
12:
|
||||
- name: Christmas Day
|
||||
regions: [ups]
|
||||
mday: 25
|
||||
observed: to_weekday_if_weekend
|
||||
- name: New Year's Eve
|
||||
regions: [ups]
|
||||
mday: 31
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,5,26) => 'Memorial Day',
|
||||
Date.civil(2008,7,4) => 'Independence Day',
|
||||
Date.civil(2008,9,1) => 'Labor Day',
|
||||
Date.civil(2008,11,27) => 'Thanksgiving',
|
||||
Date.civil(2008,11,28) => 'Day After Thanksgiving',
|
||||
Date.civil(2008,12,25) => 'Christmas Day',
|
||||
Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :ups)[0][:name]
|
||||
end
|
|
@ -20,5 +20,6 @@ The following definition files are included in this installation:
|
|||
* holidays/scandinavia
|
||||
* holidays/se
|
||||
* holidays/united_nations
|
||||
* holidays/ups
|
||||
* holidays/us
|
||||
* holidays/za
|
||||
|
|
32
lib/holidays/nyse.rb
Normal file
32
lib/holidays/nyse.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/nyse.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'holidays/nyse'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module NYSE # :nodoc:
|
||||
DEFINED_REGIONS = [:nyse]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:nyse]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}],
|
||||
11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:nyse]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:nyse]},
|
||||
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:nyse]}],
|
||||
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:nyse]}],
|
||||
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:nyse]}],
|
||||
2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:nyse]}],
|
||||
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:nyse]}]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::NYSE::DEFINED_REGIONS, Holidays::NYSE::HOLIDAYS_BY_MONTH)
|
31
lib/holidays/ups.rb
Normal file
31
lib/holidays/ups.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/ups.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'holidays/ups'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module UPS # :nodoc:
|
||||
DEFINED_REGIONS = [:ups]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:ups]}],
|
||||
11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:ups]},
|
||||
{:wday => 5, :week => 4, :name => "Day After Thanksgiving", :regions => [:ups]}],
|
||||
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]}],
|
||||
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:ups]},
|
||||
{:mday => 31, :name => "New Year's Eve", :regions => [:ups]}],
|
||||
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:ups]}],
|
||||
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:ups]}]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::UPS::DEFINED_REGIONS, Holidays::UPS::HOLIDAYS_BY_MONTH)
|
|
@ -46,7 +46,7 @@ end
|
|||
|
||||
spec = Gem::Specification.new do |s|
|
||||
s.name = 'holidays'
|
||||
s.version = '0.9.2'
|
||||
s.version = '0.9.3'
|
||||
s.author = 'Alex Dunae'
|
||||
s.homepage = 'http://code.dunae.ca/holidays'
|
||||
s.platform = Gem::Platform::RUBY
|
||||
|
|
22
test/defs/test_defs_nyse.rb
Normal file
22
test/defs/test_defs_nyse.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'holidays/nyse'
|
||||
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/nyse.yaml
|
||||
class NyseDefinitionTests < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
def test_nyse
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
||||
Date.civil(2008,2,18) => 'Presidents\' Day',
|
||||
Date.civil(2008,3,21) => 'Good Friday',
|
||||
Date.civil(2008,5,26) => 'Memorial Day',
|
||||
Date.civil(2008,7,4) => 'Independence Day',
|
||||
Date.civil(2008,9,1) => 'Labor Day',
|
||||
Date.civil(2008,11,27) => 'Thanksgiving',
|
||||
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :nyse)[0][:name]
|
||||
end
|
||||
end
|
||||
end
|
21
test/defs/test_defs_ups.rb
Normal file
21
test/defs/test_defs_ups.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'holidays/ups'
|
||||
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/ups.yaml
|
||||
class UpsDefinitionTests < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
def test_ups
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,5,26) => 'Memorial Day',
|
||||
Date.civil(2008,7,4) => 'Independence Day',
|
||||
Date.civil(2008,9,1) => 'Labor Day',
|
||||
Date.civil(2008,11,27) => 'Thanksgiving',
|
||||
Date.civil(2008,11,28) => 'Day After Thanksgiving',
|
||||
Date.civil(2008,12,25) => 'Christmas Day',
|
||||
Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :ups)[0][:name]
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue