eitil 1.1.3 → 1.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1d078f5e3e79e4849d54692fcbfa418bec803333e69dcc6f4df72b09941ff31
4
- data.tar.gz: 9e1232d63ae999afbbb5d0df2405fdb1ca038269096a73a8f8b82dc29de9ab1e
3
+ metadata.gz: b566e2911d13c9952ef93916e929e1bf4666790e2d07934ccc3cb7d00f421319
4
+ data.tar.gz: d492741da447ce1777c79a07c1968acc611f558eec690d933c3e8eff94422f4b
5
5
  SHA512:
6
- metadata.gz: 6d80703adbc3faf1be7faf8ffdbed5d70b7e04f9edbd7f88dba9baef9b5e3b7b79cf8091732d0e03aaa28fa0ec8efe66260da9d64ca595fd31b64f667e742160
7
- data.tar.gz: cf450d841ca4f1a528ba3aa2d7be7a018b9a4ae08f2a16e491cec44ce69245e8f7a3193ce00824a3b7fda959917c0127d1528c979bce14a4b5c221a79b4bfdec
6
+ metadata.gz: 27376302a08134d0f7b14d55c4dda41eabd230b93cd1bce4f719d12505241e817779fc4feaa83e03443cc910516e33e477c10760ed9be7d5c543b2b53d98e2ae
7
+ data.tar.gz: 2fe73ac66fe0ef8bfc64260fc95e05f4a5c8dee3c8f7afb2c376da25fc65b1b93ab8da6b008bbb5d31537789d1c8b697258f87dbf9bde956f3c849ffa7e46bd1
@@ -10,9 +10,12 @@ module EitilIntegrate::RubyXL
10
10
  format_ints_to_floats
11
11
  end
12
12
 
13
- def format_time_strings
14
- @hash.transform_values! { |array| array.map { |item| incomplete_time_string?(item) ? "#{item}:00" : item } }
15
- end
13
+ # outcommented method in favour of AutoSum#chronic_sum_array: no longer accept days, since the method excepts
14
+ # either hh:mm or hh:mm:ss
15
+
16
+ # def format_time_strings
17
+ # @hash.transform_values! { |array| array.map { |item| incomplete_time_string?(item) ? "#{item}:00" : item } }
18
+ # end
16
19
 
17
20
  def incomplete_time_string?(string)
18
21
  string.is_a?(String) && string.length == 5 && string.scan(/\d{2}:\d{2}/)
@@ -22,15 +22,30 @@ module EitilIntegrate::RubyXL
22
22
  end
23
23
 
24
24
  def chronic_sum_array(array)
25
- sum = array.map { |item| ChronicDuration.parse(item) }.compact.sum
26
- hours = format_time(sum / (60 * 60))
27
- sum = sum % (60 * 60)
28
- minutes = format_time(sum / 60)
29
- seconds = format_time(sum % 60)
30
-
31
- # currently doesn't return seconds, since those will never
32
- # be set (?) and screw the consistency of data formatting
33
- ["#{hours}:#{minutes}"]
25
+
26
+ #total minutes, hours and days
27
+ tm, th, td = [0]*3
28
+
29
+ array.each do |time_string|
30
+
31
+ # add empty 0's, to avoid defining nil values when time values are absent
32
+ h, m, s = *time_string.split(':').map(&:to_i), *[0]*3
33
+ tm += m; th += h
34
+
35
+ end
36
+
37
+ # parsing times into maxes (60 m, 24 h, ∞ days)
38
+ th += tm / 60
39
+ tm = tm % 60
40
+ td += th / 24
41
+ th = th % 24
42
+
43
+ # formatting strings
44
+ sd = td.to_s
45
+ sh = th.to_s.rjust(2,'0')
46
+ sm = tm.to_s.rjust(2,'0')
47
+
48
+ [[sd, sh, sm].join(':')]
34
49
  end
35
50
 
36
51
  def format_time(time)
data/lib/eitil/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eitil
2
2
 
3
- VERSION = '1.1.3'
3
+ VERSION = '1.1.4'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eitil
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Schrofer