business-days 0.1.0 → 0.1.1
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 +13 -4
- 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: d3bbc892749b3892c56eff2cb8f86a7f7f1bd39e
|
4
|
+
data.tar.gz: ca2333f85d9465b9bb70d429784611e46fd0a1a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39675014fef8f85089cfad6a484c2890e2bdd757998b9bd1cdb36b057fc46b57d17ce6a57331d8552f5beb531fcf95238fa6622b3261f9f2fb773f4a85fc3077
|
7
|
+
data.tar.gz: 3f1df86059f02b4226e9d192dc6ab2f25e7a79704de010dbe0279dd972c44d8a86843af13288bffd304d289eedadbaa4daae8e3bc5da45e41f82781d2115d2dc
|
data/lib/business-days.rb
CHANGED
@@ -32,11 +32,20 @@ class BusinessDaysSingleton
|
|
32
32
|
# Compute the date obtained by adding the given amount of business days to the given time.
|
33
33
|
#
|
34
34
|
# @param days [Integer] how many business days to add to given time.
|
35
|
-
# @param time [Time] the start time from which the business days will be added.
|
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.
|
36
37
|
# @return [Date] the computed business day
|
37
|
-
def business_days_from_utc_time(days, time)
|
38
|
-
#
|
39
|
-
|
38
|
+
def business_days_from_utc_time(days, time, reference=nil)
|
39
|
+
# Set reference to given time if no reference is passed
|
40
|
+
if reference.nil?
|
41
|
+
reference = time
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get offset from reference data (based on Brasilia timezone)
|
45
|
+
offset = reference.in_time_zone('Brasilia').formatted_offset()
|
46
|
+
|
47
|
+
# Get date from time in reference offset
|
48
|
+
date = (time + offset.to_i.hours).to_date
|
40
49
|
|
41
50
|
# Add days until we reach the specified business days
|
42
51
|
count = 0
|
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: 0.1.
|
4
|
+
version: 0.1.1
|
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-02
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|