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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/business-days.rb +6 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97396fdf08a72c4fa9a96cf86f22db60c6227e33
4
- data.tar.gz: a248e695049fa8ada91e377761fedab47f99ffb5
3
+ metadata.gz: d7105eb2e425985c8181e8072d969fa20212e8d9
4
+ data.tar.gz: f840d5b52c8c489a56fdcd544f30f11cd036e947
5
5
  SHA512:
6
- metadata.gz: 7b5abfefe93901caa1f17a3a285a7245b9307581965df21d70d5388a91d835b1ef96abfaa18c7d8db57fd7577681e7cb6f80e6e498cfaa87ea83cc63add5d1da
7
- data.tar.gz: e7d89dc1b78dd073d499f3186721b13b75463c94ec2793babba9f0b5b532078698e81f85ef5bb951c32d475b26644fc02db9764ef5948b8039a88f24bc0ea87c
6
+ metadata.gz: ec03a964c382a479491f9226b8f4a645cb98058cd910f304f02a7c0001cb897d4206846c475e29fde53df18b03eb9c94e28ce3cd5eecb10a0cbe11260a7fa55e
7
+ data.tar.gz: 63ed47b9ca9e5cb4d7454c40a91676202b16212dee96e2b3ef77e5d9357cb6f984153e18f5adc69a821a7b82014e41c517040be3dccef321a451b8ea122f1f1d
@@ -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, reference=nil)
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 = reference.in_time_zone('Brasilia').formatted_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
- date += 1.days
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: 1.0.1
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-03-02 00:00:00.000000000 Z
11
+ date: 2018-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport