business-days 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/business-days.rb +6 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7105eb2e425985c8181e8072d969fa20212e8d9
|
4
|
+
data.tar.gz: f840d5b52c8c489a56fdcd544f30f11cd036e947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec03a964c382a479491f9226b8f4a645cb98058cd910f304f02a7c0001cb897d4206846c475e29fde53df18b03eb9c94e28ce3cd5eecb10a0cbe11260a7fa55e
|
7
|
+
data.tar.gz: 63ed47b9ca9e5cb4d7454c40a91676202b16212dee96e2b3ef77e5d9357cb6f984153e18f5adc69a821a7b82014e41c517040be3dccef321a451b8ea122f1f1d
|
data/lib/business-days.rb
CHANGED
@@ -33,16 +33,10 @@ class BusinessDaysSingleton
|
|
33
33
|
#
|
34
34
|
# @param days [Integer] how many business days to add to given time.
|
35
35
|
# @param time [Time] the start time in UTC from which the business days will be added.
|
36
|
-
# @param reference [Time] the reference time in UTC from which we will compute daylight saving.
|
37
36
|
# @return [Time] the computed business day in UTC time (at midnight in Brasilia time)
|
38
|
-
def business_days_from_utc_time(days, time
|
39
|
-
# Set reference to given time if no reference is passed
|
40
|
-
if reference.nil?
|
41
|
-
reference = time
|
42
|
-
end
|
43
|
-
|
37
|
+
def business_days_from_utc_time(days, time)
|
44
38
|
# Get offset from reference data (based on Brasilia timezone)
|
45
|
-
offset =
|
39
|
+
offset = time.in_time_zone('Brasilia').formatted_offset()
|
46
40
|
|
47
41
|
# Get date from time in reference offset
|
48
42
|
date = (time + offset.to_i.hours).to_date
|
@@ -50,7 +44,10 @@ class BusinessDaysSingleton
|
|
50
44
|
# Add days until we reach the specified business days
|
51
45
|
count = 0
|
52
46
|
while count < days
|
53
|
-
|
47
|
+
time += 24*60*60
|
48
|
+
|
49
|
+
offset = time.in_time_zone('Brasilia').formatted_offset()
|
50
|
+
date = (time + offset.to_i.hours).to_date
|
54
51
|
if business_day?(date)
|
55
52
|
count +=1
|
56
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business-days
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Allan Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|