roxbury 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/roxbury/business_calendar.rb +17 -5
- data/lib/roxbury/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '083b94bc5b909ea14a3607950f68fc1cdf22c6319bec0dd97fa8bc125ce8de54'
|
4
|
+
data.tar.gz: 464e95eda05d38625f90b7ea63ff38c4554de4045a58cb60e3959337427867e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e45ddec1a5f4a24a66e171c9d8bff69018ab39a1c67759163f5b352c68be6271e86a424467b343a71ce7f1d14bda57f9c02a41c055cd84eed0ee1c92f233a05f
|
7
|
+
data.tar.gz: bdb32f0528ba2d0f2d1408652fa61795bf07935cf8c1b0796495f2720b319cd74aa00a6e1441f8839943c6ada28629ae2431a62cefb9a844a301b915ab1029f6
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
roxbury (0.
|
4
|
+
roxbury (0.2.1)
|
5
5
|
activesupport (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -75,7 +75,7 @@ GEM
|
|
75
75
|
thread_safe (0.3.6)
|
76
76
|
tzinfo (1.2.5)
|
77
77
|
thread_safe (~> 0.1)
|
78
|
-
zeitwerk (2.1.
|
78
|
+
zeitwerk (2.1.10)
|
79
79
|
|
80
80
|
PLATFORMS
|
81
81
|
ruby
|
@@ -38,7 +38,7 @@ module Roxbury
|
|
38
38
|
|
39
39
|
until (bday = business_day(rolling_timestamp)).include?(rolling_timestamp + remaining_hours.hours)
|
40
40
|
remaining_hours -= bday.number_of_working_hours(from: rolling_timestamp)
|
41
|
-
rolling_timestamp =
|
41
|
+
rolling_timestamp = next_working_day(rolling_timestamp)
|
42
42
|
end
|
43
43
|
|
44
44
|
rolling_timestamp + remaining_hours.hours
|
@@ -64,7 +64,7 @@ module Roxbury
|
|
64
64
|
remaining_days = number_of_days
|
65
65
|
rolling_date = to
|
66
66
|
loop do
|
67
|
-
remaining_days -=
|
67
|
+
remaining_days -= working_hours_percentage(rolling_date)
|
68
68
|
break if remaining_days < 0
|
69
69
|
rolling_date = roll_forward rolling_date.next
|
70
70
|
end
|
@@ -86,9 +86,21 @@ module Roxbury
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
#
|
90
|
-
|
91
|
-
|
89
|
+
# If a Date is given, returns then next business day.
|
90
|
+
# Otherwise if a Time is given, snaps the date to the beginning of the next business day.
|
91
|
+
def next_working_day date
|
92
|
+
case date
|
93
|
+
when Time
|
94
|
+
roll_forward date.tomorrow.beginning_of_day
|
95
|
+
when Date
|
96
|
+
roll_forward date.tomorrow
|
97
|
+
else
|
98
|
+
raise ArgumentError, 'only Date or Time instances are allowed'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def working_hours_percentage date
|
103
|
+
business_day(date).number_of_working_hours * 1.0 / max_working_hours_in_a_day
|
92
104
|
end
|
93
105
|
|
94
106
|
def holiday? date_or_time
|
data/lib/roxbury/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roxbury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Nicolau
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|