bizhours 1.0.1 → 1.1.0
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/History.txt +4 -0
- data/README.txt +2 -1
- data/lib/bizhours.rb +6 -12
- metadata +5 -5
data/History.txt
CHANGED
data/README.txt
CHANGED
data/lib/bizhours.rb
CHANGED
@@ -4,7 +4,7 @@ require 'date'
|
|
4
4
|
|
5
5
|
|
6
6
|
module Bizhours
|
7
|
-
VERSION = '1.0
|
7
|
+
VERSION = '1.1.0'
|
8
8
|
BIZHOURS = {
|
9
9
|
:mon => [8,20],
|
10
10
|
:tue => [8,20],
|
@@ -18,7 +18,7 @@ module Bizhours
|
|
18
18
|
##
|
19
19
|
#Takes 2 timestamps and returns a duration object of hours that match BIZHOURS for day
|
20
20
|
|
21
|
-
def
|
21
|
+
def get_duration(startt, endt)
|
22
22
|
#if start and end time is on same day do the following
|
23
23
|
if (startt.yday == endt.yday && startt.year == endt.year)
|
24
24
|
openhr, closehr = business_hours_for_day(startt)
|
@@ -43,9 +43,6 @@ module Bizhours
|
|
43
43
|
return dur
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
|
-
#startd = Time.local(startt.year, startt.month, startt.day)
|
48
|
-
#endd = Time.local(endt.year, endt.month, endt.day)
|
49
46
|
|
50
47
|
duration = first_day_time(startt) + last_day_time(endt) + inbetween_day_time(startt, endt)
|
51
48
|
|
@@ -55,7 +52,7 @@ module Bizhours
|
|
55
52
|
##
|
56
53
|
# Calculate duration for first day
|
57
54
|
|
58
|
-
def
|
55
|
+
def first_day_time(startt)
|
59
56
|
#get the closehr for the day
|
60
57
|
openhr, closehr = business_hours_for_day(startt)
|
61
58
|
|
@@ -82,7 +79,7 @@ module Bizhours
|
|
82
79
|
##
|
83
80
|
# Calculate duration for last day
|
84
81
|
|
85
|
-
def
|
82
|
+
def last_day_time(endt)
|
86
83
|
openhr, closehr = business_hours_for_day(endt)
|
87
84
|
close = Time.local(endt.year, endt.month, endt.day, closehr)
|
88
85
|
stop = Time.local(endt.year, endt.month, endt.day, endt.hour, endt.min, endt.sec)
|
@@ -106,7 +103,7 @@ module Bizhours
|
|
106
103
|
##
|
107
104
|
# Calculate duration for days inbetween first and last
|
108
105
|
|
109
|
-
def
|
106
|
+
def inbetween_day_time(startt,endt)
|
110
107
|
durs = []
|
111
108
|
duration = Duration.new
|
112
109
|
startd = DateTime.new(startt.year, startt.month, startt.day)
|
@@ -134,7 +131,7 @@ module Bizhours
|
|
134
131
|
# If date has special hours it can pull them from db, otherwise it uses the BIZHOURS hash
|
135
132
|
# returns array with [openhour, closehour]
|
136
133
|
|
137
|
-
def
|
134
|
+
def business_hours_for_day(time)
|
138
135
|
|
139
136
|
##If your going to have custom hours do something like the following and comment out the diffhours = nil
|
140
137
|
#diffhours = Hour.find(:first, :conditions => ["date = ?", time.to_date] ) <-- Active Record
|
@@ -149,6 +146,3 @@ module Bizhours
|
|
149
146
|
end
|
150
147
|
end
|
151
148
|
end
|
152
|
-
|
153
|
-
#puts Bizhours.get_duration(Time.now, Time.now + 86400 + 86400 + 89998640)
|
154
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bizhours
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Curtis Carter
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-06 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,9 +30,9 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.8.2
|
34
34
|
version:
|
35
|
-
description: "== FEATURES/PROBLEMS: Edit the BIZHOURS constant to set your normal business hours for each day of the week. Supports custom hours on days as well, look at #diffhours= line in bizhours.rb for example using Rails == SYNOPSIS: require 'bizhours' Bizhours
|
35
|
+
description: "== FEATURES/PROBLEMS: Edit the BIZHOURS constant to set your normal business hours for each day of the week. Supports custom hours on days as well, look at #diffhours= line in bizhours.rb for example using Rails == SYNOPSIS: require 'bizhours' include Bizhours Object#get_duration(Time.now, Time.now + 86400) == REQUIREMENTS: Duration >= 0.1.0 == INSTALL: sudo gem install bizhours == LICENSE:"
|
36
36
|
email: curtis@rubyhq.com
|
37
37
|
executables:
|
38
38
|
- bizhours
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements: []
|
73
73
|
|
74
74
|
rubyforge_project: bizhours
|
75
|
-
rubygems_version: 1.
|
75
|
+
rubygems_version: 1.3.1
|
76
76
|
signing_key:
|
77
77
|
specification_version: 2
|
78
78
|
summary: A utility to determine the ammount of business hours between two timestamps
|