timerage 1.1.0 → 1.1.1
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 +4 -4
- data/lib/timerage/time_interval.rb +16 -10
- data/lib/timerage/version.rb +1 -1
- 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: 0365b44846200c067bdec2f0f12e0c37f6619896
|
|
4
|
+
data.tar.gz: 6c2b0ea9a6fe86a7f163914ab1b4b4879c21f0dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73b6ee091ef7fc1994aa0436b277daaada95ed0f1f07360e4c3eda3da8311ff0005661534993dfdf614b1a86441a47fac41f824d81c1537c085c57c0cc8de0a2
|
|
7
|
+
data.tar.gz: be398eac47d357eba8e1aa05c584aa872924fb639bf462745db0f6a6f19a014ca9e1549904cb9cdaa8f9ac1d33060464f699eae3c8e634535f503fa96f59ba24
|
|
@@ -30,20 +30,26 @@ module Timerage
|
|
|
30
30
|
an_obj.respond_to?(:end)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
# ---
|
|
34
|
+
#
|
|
35
|
+
# This is implemented in a slightly more procedural style than i
|
|
36
|
+
# prefer because we want to work well with ActiveSupport::Duration
|
|
37
|
+
# steps. Adding a Duration to a time uses the timezone (dst, etc),
|
|
38
|
+
# leap second and leap day aware `#advance` method in
|
|
39
|
+
# ActiveSupport. However, multiplying a Duration by a number
|
|
40
|
+
# returns a number, rather than a duration. This, in turn, means
|
|
41
|
+
# that adding a duration times a number to a time results in
|
|
42
|
+
# Timely incorrect results. So we do it the hard way.
|
|
33
43
|
def time_enumerator(step)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
->(nxt) { nxt <= self.end }
|
|
38
|
-
end
|
|
44
|
+
count = (self.end - self.begin).div(step)
|
|
45
|
+
count += 1 if !exclude_end? and (self.end - self.begin) % step == 0
|
|
46
|
+
# We've included our end if it should be
|
|
39
47
|
|
|
40
48
|
Enumerator.new do |y|
|
|
41
|
-
|
|
49
|
+
y << last = self.begin
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
y <<
|
|
45
|
-
|
|
46
|
-
nxt += step
|
|
51
|
+
(count-1).times do
|
|
52
|
+
y << last = last + step
|
|
47
53
|
end
|
|
48
54
|
end
|
|
49
55
|
end
|
data/lib/timerage/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: timerage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Williams
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-05-
|
|
12
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|