is_business_day 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +5 -3
  3. data/lib/is_business_day.rb +19 -4
  4. data/lib/is_business_day/business_days.rb +11 -0
  5. data/lib/is_business_day/business_days/calculations.rb +29 -0
  6. data/lib/is_business_day/business_days/tests.rb +17 -0
  7. data/lib/is_business_day/christmas.rb +15 -0
  8. data/lib/is_business_day/christmas/day/calculations.rb +23 -0
  9. data/lib/is_business_day/christmas/day/tests.rb +21 -0
  10. data/lib/is_business_day/christmas/eve/calculations.rb +23 -0
  11. data/lib/is_business_day/christmas/eve/tests.rb +21 -0
  12. data/lib/is_business_day/fourth_of_july.rb +11 -0
  13. data/lib/is_business_day/fourth_of_july/calculations.rb +19 -0
  14. data/lib/is_business_day/fourth_of_july/tests.rb +17 -0
  15. data/lib/is_business_day/helpers.rb +53 -0
  16. data/lib/is_business_day/holidays.rb +31 -0
  17. data/lib/is_business_day/labor_day.rb +11 -0
  18. data/lib/is_business_day/labor_day/calculations.rb +22 -0
  19. data/lib/is_business_day/labor_day/tests.rb +18 -0
  20. data/lib/is_business_day/memorial_day.rb +11 -0
  21. data/lib/is_business_day/memorial_day/calculations.rb +24 -0
  22. data/lib/is_business_day/memorial_day/tests.rb +22 -0
  23. data/lib/is_business_day/new_years_day.rb +11 -0
  24. data/lib/is_business_day/new_years_day/calculations.rb +19 -0
  25. data/lib/is_business_day/new_years_day/tests.rb +17 -0
  26. data/lib/is_business_day/thanksgiving.rb +12 -0
  27. data/lib/is_business_day/thanksgiving/calculations.rb +24 -0
  28. data/lib/is_business_day/thanksgiving/tests.rb +22 -0
  29. data/lib/is_business_day/version.rb +1 -1
  30. data/spec/is_business_day/christmas_spec.rb +147 -0
  31. data/spec/is_business_day/fourth_of_july_spec.rb +70 -0
  32. data/spec/is_business_day/is_business_day_spec.rb +50 -0
  33. data/spec/is_business_day/labor_day_spec.rb +78 -0
  34. data/spec/is_business_day/memorial_day_spec.rb +73 -0
  35. data/spec/is_business_day/new_years_day_spec.rb +65 -0
  36. data/spec/is_business_day/thanksgiving_spec.rb +73 -0
  37. data/spec/spec_helper.rb +14 -0
  38. metadata +95 -36
  39. data/.gitignore +0 -4
  40. data/.travis.yml +0 -5
  41. data/Gemfile +0 -4
  42. data/Guardfile +0 -4
  43. data/is_business_day.gemspec +0 -26
  44. data/lib/is_business_day/active_support/core_ext/date/calculations.rb +0 -6
  45. data/lib/is_business_day/active_support/core_ext/time/calculations.rb +0 -6
  46. data/lib/is_business_day/digitalopera/business_day_calculations.rb +0 -55
  47. data/lib/is_business_day/digitalopera/holiday_calculations.rb +0 -130
  48. data/lib/rails/generators/is_business_day/install/install_generator.rb +0 -16
  49. data/lib/rails/generators/is_business_day/install/templates/is_business_day.rb +0 -1
  50. data/spec/active_support/core_ext/date/calculations_spec.rb +0 -165
  51. data/spec/active_support/core_ext/time/calculations_spec.rb +0 -165
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in is_business_day.gemspec
4
- gemspec
data/Guardfile DELETED
@@ -1,4 +0,0 @@
1
- guard 'rspec', :version => 2, :cli => '--color --format doc' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb}) { |match| "spec/#{match[1]}_spec.rb" }
4
- end
@@ -1,26 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "is_business_day/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "is_business_day"
7
- s.version = IsBusinessDay::VERSION
8
- s.authors = ["JD Hendrickson"]
9
- s.email = ["jd@digitalopera.com"]
10
- s.homepage = ""
11
- s.summary = %q{Simple business day detection}
12
- s.description = %q{Adds some methods to the Ruby Date object for testing whether or not a specific date falls on a valid business day or not}
13
-
14
- s.rubyforge_project = "is_business_day"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- # Dependencies --------------------------------------------------------------
22
- s.add_development_dependency "rspec", "~> 2.6"
23
- s.add_development_dependency "guard-rspec", "~> 0.0"
24
- s.add_development_dependency "rake", "~> 0.9.2"
25
- s.add_dependency "activesupport", "~>3.0"
26
- end
@@ -1,6 +0,0 @@
1
- require 'date'
2
-
3
- class Date
4
- include DigitalOpera::BusinessDayCalculations
5
- include DigitalOpera::HolidayCalculations
6
- end
@@ -1,6 +0,0 @@
1
- require 'time'
2
-
3
- class Time
4
- include DigitalOpera::BusinessDayCalculations
5
- include DigitalOpera::HolidayCalculations
6
- end
@@ -1,55 +0,0 @@
1
- require 'active_support/core_ext/numeric/time'
2
- require 'active_support/core_ext/date/calculations'
3
- require 'active_support/core_ext/time/calculations'
4
-
5
- module DigitalOpera
6
- module BusinessDayCalculations
7
- # Returns TRUE || FALSE if the date is a valid business day
8
- # this also accounts for holidays
9
- #
10
- def is_a_business_day?
11
- (self.monday? || self.tuesday? || self.wednesday? || self.thursday? || self.friday?) && self.is_not_a_holiday?
12
- end
13
-
14
- # Returns TRUE || FALSE if the date IS NOT a valid business day
15
- # this also accounts for holidays
16
- #
17
- def is_not_a_business_day?
18
- self.saturday? || self.sunday? || self.is_a_holiday?
19
- end
20
-
21
- # Returns the first business day following the date. This will account for
22
- # ANY non-business day, holidays included.
23
- #
24
- def next_business_day
25
- next_business_day = self
26
-
27
- begin
28
- next_business_day = (next_business_day.to_time + 1.day).to_date
29
- end while next_business_day.is_not_a_business_day?
30
-
31
- if self.class.name == "Time"
32
- return next_business_day.to_time
33
- else
34
- return next_business_day
35
- end
36
- end
37
-
38
- # Returns the first business day preceding the date. This will account for
39
- # ANY non-business day, holidays included.
40
- #
41
- def previous_business_day
42
- previous_business_day = self
43
-
44
- begin
45
- previous_business_day = (previous_business_day.to_time - 1.day).to_date
46
- end while previous_business_day.is_not_a_business_day?
47
-
48
- if self.class.name == "Time"
49
- return previous_business_day.to_time
50
- else
51
- return previous_business_day
52
- end
53
- end
54
- end
55
- end
@@ -1,130 +0,0 @@
1
- require 'active_support/core_ext/numeric/time'
2
- require 'active_support/core_ext/date/calculations'
3
- require 'active_support/core_ext/time/calculations'
4
- require 'active_support/core_ext/array/access'
5
-
6
- module DigitalOpera
7
- module HolidayCalculations
8
- # Returns TRUE || FALSE if the date is a recognized holiday
9
- #
10
- def is_a_holiday?
11
- self.is_memorial_day? || self.is_labor_day? || self.is_thanksgiving_day? || self.is_new_years_day? || self.is_xmas_day? || self.is_xmas_eve? || self.is_fourth_of_july?
12
- end
13
-
14
- # Returns TRUE || FALSE if the date IS NOT a recognized holiday
15
- #
16
- def is_not_a_holiday?
17
- self.is_not_memorial_day? && self.is_not_labor_day? && self.is_not_thanksgiving_day? && self.is_not_new_years_day? && self.is_not_xmas_day? && self.is_not_xmas_eve? && self.is_not_fourth_of_july?
18
- end
19
-
20
- # Labor Day (First monday in september)
21
- # http://en.wikipedia.org/wiki/Labor_Day
22
- #
23
- def labor_day_this_year
24
- september = Date.parse("01/09/#{self.year}")
25
- labor_day = september.beginning_of_month.step(september.end_of_month, 1).map{ |day| day if day.monday? }.compact.first
26
- if self.class.name == "Time"
27
- return labor_day.to_time
28
- else
29
- return labor_day
30
- end
31
- end
32
-
33
- def is_labor_day?
34
- self == self.labor_day_this_year
35
- end
36
-
37
- def is_not_labor_day?
38
- self != self.labor_day_this_year
39
- end
40
-
41
- # Memorial Day (Last monday in may)
42
- # http://en.wikipedia.org/wiki/Memorial_Day
43
- #
44
- def memorial_day_this_year
45
- may = Date.parse("01/05/#{self.year}")
46
- memorial_day = may.beginning_of_month.step(may.end_of_month, 1).map{ |day| day if day.monday? }.compact.last
47
- if self.class.name == "Time"
48
- return memorial_day.to_time
49
- else
50
- return memorial_day
51
- end
52
- end
53
-
54
- def is_memorial_day?
55
- self == self.memorial_day_this_year
56
- end
57
-
58
- def is_not_memorial_day?
59
- self != self.memorial_day_this_year
60
- end
61
-
62
- # Thanksgiving Day (fourth thursday in november in the US)
63
- # http://en.wikipedia.org/wiki/Thanksgiving
64
- #
65
- def thanksgiving_day_this_year
66
- november = Date.parse("01/11/#{self.year}")
67
- thanksgiving_day = november.beginning_of_month.step(november.end_of_month, 1).map{ |day| day if day.thursday? }.compact.fourth
68
- if self.class.name == "Time"
69
- return thanksgiving_day.to_time
70
- else
71
- return thanksgiving_day
72
- end
73
- end
74
-
75
- def is_thanksgiving_day?
76
- self == self.thanksgiving_day_this_year
77
- end
78
-
79
- def is_not_thanksgiving_day?
80
- self != self.thanksgiving_day_this_year
81
- end
82
-
83
- # Christmas Day (December 25th) & Christmas Eve (December 24th)
84
- # Since these holidays do not change from year to year, we are only providing
85
- # boolean checks
86
- #
87
- def is_christmas_day?
88
- self.month == 12 && self.mday == 25
89
- end
90
- alias_method :is_xmas_day?, :is_christmas_day?
91
-
92
- def is_not_christmas_day?
93
- self.month != 12 || self.mday != 25
94
- end
95
- alias_method :is_not_xmas_day?, :is_not_christmas_day?
96
-
97
- def is_christmas_eve?
98
- self.month == 12 && self.mday == 24
99
- end
100
- alias_method :is_xmas_eve?, :is_christmas_eve?
101
-
102
- def is_not_christmas_eve?
103
- self.month != 12 || self.mday != 24
104
- end
105
- alias_method :is_not_xmas_eve?, :is_not_christmas_eve?
106
-
107
- # New Years Day (January 1st)
108
- # Since this holiday does not change, it is always January 1st, we are only providing
109
- # boolean checks
110
- #
111
- def is_new_years_day?
112
- self.yday == 1
113
- end
114
-
115
- def is_not_new_years_day?
116
- self.yday != 1
117
- end
118
-
119
- # July 4th
120
- # Since this holiday does not change we are only providing boolean checks
121
- #
122
- def is_fourth_of_july?
123
- self.month == 7 && self.mday == 4
124
- end
125
-
126
- def is_not_fourth_of_july?
127
- self.month != 7 || self.mday != 4
128
- end
129
- end
130
- end
@@ -1,16 +0,0 @@
1
-
2
- module IsBusinessDay
3
- module Generators
4
- class InstallGenerator < Rails::Generators::Base
5
- desc "Creates an initializer file that can be used to specify business day rules"
6
-
7
- def self.source_root
8
- @_ibd_source_root ||= File.expand_path("../templates", __FILE__)
9
- end
10
-
11
- def create_initializer_file
12
- template "is_business_day.rb", File.join('config/initializers', "is_business_day.rb")
13
- end
14
- end
15
- end
16
- end
@@ -1 +0,0 @@
1
- # is_business_day initializer
@@ -1,165 +0,0 @@
1
- require "is_business_day"
2
-
3
- describe Date do
4
- it "should know that monday is a valid business day" do
5
- Date.parse("26/03/2012").is_a_business_day?.should be_true
6
- end
7
-
8
- it "should know that tuesday is a valid business day" do
9
- Date.parse("27/03/2012").is_a_business_day?.should be_true
10
- end
11
-
12
- it "should know that wednesday is a valid business day" do
13
- Date.parse("28/03/2012").is_a_business_day?.should be_true
14
- end
15
-
16
- it "should know that thursday is a valid business day" do
17
- Date.parse("29/03/2012").is_a_business_day?.should be_true
18
- end
19
-
20
- it "should know that friday is a valid business day" do
21
- Date.parse("30/03/2012").is_a_business_day?.should be_true
22
- end
23
-
24
- it "should know that saturday is not a valid business day" do
25
- Date.parse("31/03/2012").is_not_a_business_day?.should be_true
26
- Date.parse("31/03/2012").is_a_business_day?.should be_false
27
- end
28
-
29
- it "should know that sunday is not a valid business day" do
30
- Date.parse("01/04/2012").is_not_a_business_day?.should be_true
31
- Date.parse("01/04/2012").is_a_business_day?.should be_false
32
- end
33
-
34
- it "should know that the next business day for a friday is monday" do
35
- next_business_day = Date.parse("30/03/2012").next_business_day
36
- next_business_day.should eql(Date.parse("02/04/2012"))
37
- next_business_day.monday?.should be_true
38
- end
39
-
40
- it "should know that the business day previous a monday was friday" do
41
- previous_business_day = Date.parse("26/03/2012").previous_business_day
42
- previous_business_day.should eql(Date.parse("23/03/2012"))
43
- previous_business_day.friday?.should be_true
44
- end
45
-
46
- it "should know when labor day is" do
47
- test_date = Date.parse("06/06/2012")
48
- test_date.labor_day_this_year.should eql(Date.parse("03/09/2012"))
49
- end
50
-
51
- it "should know when memorial day is" do
52
- test_date = Date.parse("06/06/2012")
53
- test_date.memorial_day_this_year.should eql(Date.parse("28/05/2012"))
54
- end
55
-
56
- it "should know when thanksgiving is" do
57
- test_date = Date.parse("06/06/2012")
58
- test_date.thanksgiving_day_this_year.should eql(Date.parse("22/11/2012"))
59
- end
60
-
61
- it "should be able to tell if it is memorial day and that it is not a valid business day" do
62
- bad_date = Date.parse("06/06/2012")
63
- good_date = Date.parse("28/05/2012")
64
- bad_date.is_memorial_day?.should be_false
65
- bad_date.is_not_memorial_day?.should be_true
66
- good_date.is_memorial_day?.should be_true
67
- good_date.is_not_memorial_day?.should be_false
68
- good_date.is_not_a_business_day?.should be_true
69
- good_date.is_a_business_day?.should be_false
70
- end
71
-
72
- it "should be able to tell if it is labor day and that it is not a valid business day" do
73
- bad_date = Date.parse("06/06/2012")
74
- good_date = Date.parse("03/09/2012")
75
- bad_date.is_labor_day?.should be_false
76
- bad_date.is_not_labor_day?.should be_true
77
- good_date.is_labor_day?.should be_true
78
- good_date.is_not_labor_day?.should be_false
79
- good_date.is_not_a_business_day?.should be_true
80
- good_date.is_a_business_day?.should be_false
81
- end
82
-
83
- it "should be able to tell if it is thanksgiving day and that it is not a valid business day" do
84
- bad_date = Date.parse("06/06/2012")
85
- good_date = Date.parse("22/11/2012")
86
- bad_date.is_thanksgiving_day?.should be_false
87
- bad_date.is_not_thanksgiving_day?.should be_true
88
- good_date.is_thanksgiving_day?.should be_true
89
- good_date.is_not_thanksgiving_day?.should be_false
90
- good_date.is_not_a_business_day?.should be_true
91
- good_date.is_a_business_day?.should be_false
92
- end
93
-
94
- it "should be able to tell if it is xmas day and that it is not a valid business day" do
95
- bad_date = Date.parse("06/06/2012")
96
- good_date = Date.parse("25/12/2012")
97
- bad_date.is_christmas_day?.should be_false
98
- bad_date.is_not_christmas_day?.should be_true
99
- good_date.is_christmas_day?.should be_true
100
- good_date.is_not_christmas_day?.should be_false
101
- good_date.is_not_a_business_day?.should be_true
102
- good_date.is_a_business_day?.should be_false
103
- end
104
-
105
- it "should be able to tell if it is xmas eve and that it is not a valid business day" do
106
- bad_date = Date.parse("06/06/2012")
107
- good_date = Date.parse("24/12/2012")
108
- bad_date.is_christmas_eve?.should be_false
109
- bad_date.is_not_christmas_eve?.should be_true
110
- good_date.is_christmas_eve?.should be_true
111
- good_date.is_not_christmas_eve?.should be_false
112
- good_date.is_not_a_business_day?.should be_true
113
- good_date.is_a_business_day?.should be_false
114
- end
115
-
116
- it "should be able to tell if it is new year's day and that it is not a valid business day" do
117
- bad_date = Date.parse("06/06/2012")
118
- good_date = Date.parse("01/01/2012")
119
- bad_date.is_new_years_day?.should be_false
120
- bad_date.is_not_new_years_day?.should be_true
121
- good_date.is_new_years_day?.should be_true
122
- good_date.is_not_new_years_day?.should be_false
123
- good_date.is_not_a_business_day?.should be_true
124
- good_date.is_a_business_day?.should be_false
125
- end
126
-
127
- it "should be able to tell if it is the fourth of july and that it is not a valid business day" do
128
- bad_date = Date.parse("06/06/2012")
129
- good_date = Date.parse("04/07/2012")
130
- bad_date.is_fourth_of_july?.should be_false
131
- bad_date.is_not_fourth_of_july?.should be_true
132
- good_date.is_fourth_of_july?.should be_true
133
- good_date.is_not_fourth_of_july?.should be_false
134
- good_date.is_not_a_business_day?.should be_true
135
- good_date.is_a_business_day?.should be_false
136
- end
137
-
138
- it "should be able to tell if it is a holiday or not" do
139
- new_years_day = Date.parse("01/01/2012")
140
- memorial_day = Date.parse("28/05/2012")
141
- fourth_of_july = Date.parse("04/07/2012")
142
- labor_day = Date.parse("03/09/2012")
143
- thanksgiving_day = Date.parse("22/11/2012")
144
- xmas_eve = Date.parse("24/12/2012")
145
- xmas_day = Date.parse("25/12/2012")
146
- bad_date = Date.parse("06/06/2012")
147
-
148
- new_years_day.is_a_holiday?.should be_true
149
- new_years_day.is_not_a_holiday?.should be_false
150
- memorial_day.is_a_holiday?.should be_true
151
- memorial_day.is_not_a_holiday?.should be_false
152
- fourth_of_july.is_a_holiday?.should be_true
153
- fourth_of_july.is_not_a_holiday?.should be_false
154
- labor_day.is_a_holiday?.should be_true
155
- labor_day.is_not_a_holiday?.should be_false
156
- thanksgiving_day.is_a_holiday?.should be_true
157
- thanksgiving_day.is_not_a_holiday?.should be_false
158
- xmas_eve.is_a_holiday?.should be_true
159
- xmas_eve.is_not_a_holiday?.should be_false
160
- xmas_day.is_a_holiday?.should be_true
161
- xmas_day.is_not_a_holiday?.should be_false
162
- bad_date.is_a_holiday?.should be_false
163
- bad_date.is_not_a_holiday?.should be_true
164
- end
165
- end
@@ -1,165 +0,0 @@
1
- require "is_business_day"
2
-
3
- describe Time do
4
- it "should know that monday is a valid business day" do
5
- Time.parse("26/03/2012").is_a_business_day?.should be_true
6
- end
7
-
8
- it "should know that tuesday is a valid business day" do
9
- Time.parse("27/03/2012").is_a_business_day?.should be_true
10
- end
11
-
12
- it "should know that wednesday is a valid business day" do
13
- Time.parse("28/03/2012").is_a_business_day?.should be_true
14
- end
15
-
16
- it "should know that thursday is a valid business day" do
17
- Time.parse("29/03/2012").is_a_business_day?.should be_true
18
- end
19
-
20
- it "should know that friday is a valid business day" do
21
- Time.parse("30/03/2012").is_a_business_day?.should be_true
22
- end
23
-
24
- it "should know that saturday is not a valid business day" do
25
- Time.parse("31/03/2012").is_not_a_business_day?.should be_true
26
- Time.parse("31/03/2012").is_a_business_day?.should be_false
27
- end
28
-
29
- it "should know that sunday is not a valid business day" do
30
- Time.parse("01/04/2012").is_not_a_business_day?.should be_true
31
- Time.parse("01/04/2012").is_a_business_day?.should be_false
32
- end
33
-
34
- it "should know that the next business day for a friday is monday" do
35
- next_business_day = Time.parse("30/03/2012").next_business_day
36
- next_business_day.should eql(Time.parse("02/04/2012"))
37
- next_business_day.monday?.should be_true
38
- end
39
-
40
- it "should know that the business day previous a monday was friday" do
41
- previous_business_day = Time.parse("26/03/2012").previous_business_day
42
- previous_business_day.should eql(Time.parse("23/03/2012"))
43
- previous_business_day.friday?.should be_true
44
- end
45
-
46
- it "should know when labor day is" do
47
- test_time = Time.parse("06/06/2012")
48
- test_time.labor_day_this_year.should eql(Time.parse("03/09/2012"))
49
- end
50
-
51
- it "should know when memorial day is" do
52
- test_time = Time.parse("06/06/2012")
53
- test_time.memorial_day_this_year.should eql(Time.parse("28/05/2012"))
54
- end
55
-
56
- it "should know when thanksgiving is" do
57
- test_time = Time.parse("06/06/2012")
58
- test_time.thanksgiving_day_this_year.should eql(Time.parse("22/11/2012"))
59
- end
60
-
61
- it "should be able to tell if it is memorial day and that it is not a valid business day" do
62
- bad_date = Time.parse("06/06/2012")
63
- good_date = Time.parse("28/05/2012")
64
- bad_date.is_memorial_day?.should be_false
65
- bad_date.is_not_memorial_day?.should be_true
66
- good_date.is_memorial_day?.should be_true
67
- good_date.is_not_memorial_day?.should be_false
68
- good_date.is_not_a_business_day?.should be_true
69
- good_date.is_a_business_day?.should be_false
70
- end
71
-
72
- it "should be able to tell if it is labor day and that it is not a valid business day" do
73
- bad_date = Time.parse("06/06/2012")
74
- good_date = Time.parse("03/09/2012")
75
- bad_date.is_labor_day?.should be_false
76
- bad_date.is_not_labor_day?.should be_true
77
- good_date.is_labor_day?.should be_true
78
- good_date.is_not_labor_day?.should be_false
79
- good_date.is_not_a_business_day?.should be_true
80
- good_date.is_a_business_day?.should be_false
81
- end
82
-
83
- it "should be able to tell if it is thanksgiving day and that it is not a valid business day" do
84
- bad_date = Time.parse("06/06/2012")
85
- good_date = Time.parse("22/11/2012")
86
- bad_date.is_thanksgiving_day?.should be_false
87
- bad_date.is_not_thanksgiving_day?.should be_true
88
- good_date.is_thanksgiving_day?.should be_true
89
- good_date.is_not_thanksgiving_day?.should be_false
90
- good_date.is_not_a_business_day?.should be_true
91
- good_date.is_a_business_day?.should be_false
92
- end
93
-
94
- it "should be able to tell if it is xmas day and that it is not a valid business day" do
95
- bad_date = Time.parse("06/06/2012")
96
- good_date = Time.parse("25/12/2012")
97
- bad_date.is_christmas_day?.should be_false
98
- bad_date.is_not_christmas_day?.should be_true
99
- good_date.is_christmas_day?.should be_true
100
- good_date.is_not_christmas_day?.should be_false
101
- good_date.is_not_a_business_day?.should be_true
102
- good_date.is_a_business_day?.should be_false
103
- end
104
-
105
- it "should be able to tell if it is xmas eve and that it is not a valid business day" do
106
- bad_date = Time.parse("06/06/2012")
107
- good_date = Time.parse("24/12/2012")
108
- bad_date.is_christmas_eve?.should be_false
109
- bad_date.is_not_christmas_eve?.should be_true
110
- good_date.is_christmas_eve?.should be_true
111
- good_date.is_not_christmas_eve?.should be_false
112
- good_date.is_not_a_business_day?.should be_true
113
- good_date.is_a_business_day?.should be_false
114
- end
115
-
116
- it "should be able to tell if it is new year's day and that it is not a valid business day" do
117
- bad_date = Time.parse("06/06/2012")
118
- good_date = Time.parse("01/01/2012")
119
- bad_date.is_new_years_day?.should be_false
120
- bad_date.is_not_new_years_day?.should be_true
121
- good_date.is_new_years_day?.should be_true
122
- good_date.is_not_new_years_day?.should be_false
123
- good_date.is_not_a_business_day?.should be_true
124
- good_date.is_a_business_day?.should be_false
125
- end
126
-
127
- it "should be able to tell if it is the fourth of july and that it is not a valid business day" do
128
- bad_date = Time.parse("06/06/2012")
129
- good_date = Time.parse("04/07/2012")
130
- bad_date.is_fourth_of_july?.should be_false
131
- bad_date.is_not_fourth_of_july?.should be_true
132
- good_date.is_fourth_of_july?.should be_true
133
- good_date.is_not_fourth_of_july?.should be_false
134
- good_date.is_not_a_business_day?.should be_true
135
- good_date.is_a_business_day?.should be_false
136
- end
137
-
138
- it "should be able to tell if it is a holiday or not" do
139
- new_years_day = Time.parse("01/01/2012")
140
- memorial_day = Time.parse("28/05/2012")
141
- fourth_of_july = Time.parse("04/07/2012")
142
- labor_day = Time.parse("03/09/2012")
143
- thanksgiving_day = Time.parse("22/11/2012")
144
- xmas_eve = Time.parse("24/12/2012")
145
- xmas_day = Time.parse("25/12/2012")
146
- bad_date = Time.parse("06/06/2012")
147
-
148
- new_years_day.is_a_holiday?.should be_true
149
- new_years_day.is_not_a_holiday?.should be_false
150
- memorial_day.is_a_holiday?.should be_true
151
- memorial_day.is_not_a_holiday?.should be_false
152
- fourth_of_july.is_a_holiday?.should be_true
153
- fourth_of_july.is_not_a_holiday?.should be_false
154
- labor_day.is_a_holiday?.should be_true
155
- labor_day.is_not_a_holiday?.should be_false
156
- thanksgiving_day.is_a_holiday?.should be_true
157
- thanksgiving_day.is_not_a_holiday?.should be_false
158
- xmas_eve.is_a_holiday?.should be_true
159
- xmas_eve.is_not_a_holiday?.should be_false
160
- xmas_day.is_a_holiday?.should be_true
161
- xmas_day.is_not_a_holiday?.should be_false
162
- bad_date.is_a_holiday?.should be_false
163
- bad_date.is_not_a_holiday?.should be_true
164
- end
165
- end