is_business_day 0.1.1 → 0.1.2
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.
@@ -8,14 +8,14 @@ module DigitalOpera
|
|
8
8
|
# this also accounts for holidays
|
9
9
|
#
|
10
10
|
def is_a_business_day?
|
11
|
-
(self.monday? || self.tuesday? || self.wednesday? || self.thursday? || self.friday?)
|
11
|
+
(self.monday? || self.tuesday? || self.wednesday? || self.thursday? || self.friday?) && self.is_not_a_holiday?
|
12
12
|
end
|
13
13
|
|
14
14
|
# Returns TRUE || FALSE if the date IS NOT a valid business day
|
15
15
|
# this also accounts for holidays
|
16
16
|
#
|
17
17
|
def is_not_a_business_day?
|
18
|
-
self.saturday? || self.sunday?
|
18
|
+
self.saturday? || self.sunday? || self.is_a_holiday?
|
19
19
|
end
|
20
20
|
|
21
21
|
# Returns the first business day following the date. This will account for
|
@@ -58,67 +58,81 @@ describe Date do
|
|
58
58
|
test_date.thanksgiving_day_this_year.should eql(Date.parse("22/11/2012"))
|
59
59
|
end
|
60
60
|
|
61
|
-
it "should be able to tell if it is memorial day" do
|
61
|
+
it "should be able to tell if it is memorial day and that it is not a valid business day" do
|
62
62
|
bad_date = Date.parse("06/06/2012")
|
63
63
|
good_date = Date.parse("28/05/2012")
|
64
64
|
bad_date.is_memorial_day?.should be_false
|
65
65
|
bad_date.is_not_memorial_day?.should be_true
|
66
66
|
good_date.is_memorial_day?.should be_true
|
67
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
|
68
70
|
end
|
69
71
|
|
70
|
-
it "should be able to tell if it is labor day" do
|
72
|
+
it "should be able to tell if it is labor day and that it is not a valid business day" do
|
71
73
|
bad_date = Date.parse("06/06/2012")
|
72
74
|
good_date = Date.parse("03/09/2012")
|
73
75
|
bad_date.is_labor_day?.should be_false
|
74
76
|
bad_date.is_not_labor_day?.should be_true
|
75
77
|
good_date.is_labor_day?.should be_true
|
76
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
|
77
81
|
end
|
78
82
|
|
79
|
-
it "should be able to tell if it is thanksgiving day" do
|
83
|
+
it "should be able to tell if it is thanksgiving day and that it is not a valid business day" do
|
80
84
|
bad_date = Date.parse("06/06/2012")
|
81
85
|
good_date = Date.parse("22/11/2012")
|
82
86
|
bad_date.is_thanksgiving_day?.should be_false
|
83
87
|
bad_date.is_not_thanksgiving_day?.should be_true
|
84
88
|
good_date.is_thanksgiving_day?.should be_true
|
85
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
|
86
92
|
end
|
87
93
|
|
88
|
-
it "should be able to tell if it is xmas day" do
|
94
|
+
it "should be able to tell if it is xmas day and that it is not a valid business day" do
|
89
95
|
bad_date = Date.parse("06/06/2012")
|
90
96
|
good_date = Date.parse("25/12/2012")
|
91
97
|
bad_date.is_christmas_day?.should be_false
|
92
98
|
bad_date.is_not_christmas_day?.should be_true
|
93
99
|
good_date.is_christmas_day?.should be_true
|
94
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
|
95
103
|
end
|
96
104
|
|
97
|
-
it "should be able to tell if it is xmas eve" do
|
105
|
+
it "should be able to tell if it is xmas eve and that it is not a valid business day" do
|
98
106
|
bad_date = Date.parse("06/06/2012")
|
99
107
|
good_date = Date.parse("24/12/2012")
|
100
108
|
bad_date.is_christmas_eve?.should be_false
|
101
109
|
bad_date.is_not_christmas_eve?.should be_true
|
102
110
|
good_date.is_christmas_eve?.should be_true
|
103
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
|
104
114
|
end
|
105
115
|
|
106
|
-
it "should be able to tell if it is new year's day" do
|
116
|
+
it "should be able to tell if it is new year's day and that it is not a valid business day" do
|
107
117
|
bad_date = Date.parse("06/06/2012")
|
108
118
|
good_date = Date.parse("01/01/2012")
|
109
119
|
bad_date.is_new_years_day?.should be_false
|
110
120
|
bad_date.is_not_new_years_day?.should be_true
|
111
121
|
good_date.is_new_years_day?.should be_true
|
112
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
|
113
125
|
end
|
114
126
|
|
115
|
-
it "should be able to tell if it is the fourth of july" do
|
127
|
+
it "should be able to tell if it is the fourth of july and that it is not a valid business day" do
|
116
128
|
bad_date = Date.parse("06/06/2012")
|
117
129
|
good_date = Date.parse("04/07/2012")
|
118
130
|
bad_date.is_fourth_of_july?.should be_false
|
119
131
|
bad_date.is_not_fourth_of_july?.should be_true
|
120
132
|
good_date.is_fourth_of_july?.should be_true
|
121
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
|
122
136
|
end
|
123
137
|
|
124
138
|
it "should be able to tell if it is a holiday or not" do
|
@@ -58,67 +58,81 @@ describe Time do
|
|
58
58
|
test_time.thanksgiving_day_this_year.should eql(Time.parse("22/11/2012"))
|
59
59
|
end
|
60
60
|
|
61
|
-
it "should be able to tell if it is memorial day" do
|
61
|
+
it "should be able to tell if it is memorial day and that it is not a valid business day" do
|
62
62
|
bad_date = Time.parse("06/06/2012")
|
63
63
|
good_date = Time.parse("28/05/2012")
|
64
64
|
bad_date.is_memorial_day?.should be_false
|
65
65
|
bad_date.is_not_memorial_day?.should be_true
|
66
66
|
good_date.is_memorial_day?.should be_true
|
67
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
|
68
70
|
end
|
69
71
|
|
70
|
-
it "should be able to tell if it is labor day" do
|
72
|
+
it "should be able to tell if it is labor day and that it is not a valid business day" do
|
71
73
|
bad_date = Time.parse("06/06/2012")
|
72
74
|
good_date = Time.parse("03/09/2012")
|
73
75
|
bad_date.is_labor_day?.should be_false
|
74
76
|
bad_date.is_not_labor_day?.should be_true
|
75
77
|
good_date.is_labor_day?.should be_true
|
76
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
|
77
81
|
end
|
78
82
|
|
79
|
-
it "should be able to tell if it is thanksgiving day" do
|
83
|
+
it "should be able to tell if it is thanksgiving day and that it is not a valid business day" do
|
80
84
|
bad_date = Time.parse("06/06/2012")
|
81
85
|
good_date = Time.parse("22/11/2012")
|
82
86
|
bad_date.is_thanksgiving_day?.should be_false
|
83
87
|
bad_date.is_not_thanksgiving_day?.should be_true
|
84
88
|
good_date.is_thanksgiving_day?.should be_true
|
85
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
|
86
92
|
end
|
87
93
|
|
88
|
-
it "should be able to tell if it is xmas day" do
|
94
|
+
it "should be able to tell if it is xmas day and that it is not a valid business day" do
|
89
95
|
bad_date = Time.parse("06/06/2012")
|
90
96
|
good_date = Time.parse("25/12/2012")
|
91
97
|
bad_date.is_christmas_day?.should be_false
|
92
98
|
bad_date.is_not_christmas_day?.should be_true
|
93
99
|
good_date.is_christmas_day?.should be_true
|
94
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
|
95
103
|
end
|
96
104
|
|
97
|
-
it "should be able to tell if it is xmas eve" do
|
105
|
+
it "should be able to tell if it is xmas eve and that it is not a valid business day" do
|
98
106
|
bad_date = Time.parse("06/06/2012")
|
99
107
|
good_date = Time.parse("24/12/2012")
|
100
108
|
bad_date.is_christmas_eve?.should be_false
|
101
109
|
bad_date.is_not_christmas_eve?.should be_true
|
102
110
|
good_date.is_christmas_eve?.should be_true
|
103
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
|
104
114
|
end
|
105
115
|
|
106
|
-
it "should be able to tell if it is new year's day" do
|
116
|
+
it "should be able to tell if it is new year's day and that it is not a valid business day" do
|
107
117
|
bad_date = Time.parse("06/06/2012")
|
108
118
|
good_date = Time.parse("01/01/2012")
|
109
119
|
bad_date.is_new_years_day?.should be_false
|
110
120
|
bad_date.is_not_new_years_day?.should be_true
|
111
121
|
good_date.is_new_years_day?.should be_true
|
112
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
|
113
125
|
end
|
114
126
|
|
115
|
-
it "should be able to tell if it is the fourth of july" do
|
127
|
+
it "should be able to tell if it is the fourth of july and that it is not a valid business day" do
|
116
128
|
bad_date = Time.parse("06/06/2012")
|
117
129
|
good_date = Time.parse("04/07/2012")
|
118
130
|
bad_date.is_fourth_of_july?.should be_false
|
119
131
|
bad_date.is_not_fourth_of_july?.should be_true
|
120
132
|
good_date.is_fourth_of_july?.should be_true
|
121
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
|
122
136
|
end
|
123
137
|
|
124
138
|
it "should be able to tell if it is a holiday or not" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_business_day
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-30 00:00:00.
|
12
|
+
date: 2012-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project: is_business_day
|
123
|
-
rubygems_version: 1.8.
|
123
|
+
rubygems_version: 1.8.21
|
124
124
|
signing_key:
|
125
125
|
specification_version: 3
|
126
126
|
summary: Simple business day detection
|