timerage 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ceefa4559c94982a16c483de5def25fecf657c0
4
- data.tar.gz: 90f35a70852bc552f75e78c4af721bdcb7297838
3
+ metadata.gz: 0365b44846200c067bdec2f0f12e0c37f6619896
4
+ data.tar.gz: 6c2b0ea9a6fe86a7f163914ab1b4b4879c21f0dd
5
5
  SHA512:
6
- metadata.gz: 02599aeffd1a812a3b0404b0f101946bdbd6fa6815dec2aa2611ed1b02f2958a0468b0adb1d03333233e7d7922aa9cd9a4958e4746636f80f0a4295b3289bc7e
7
- data.tar.gz: cb0c22a9074efbce775c0b50688121981727028ca1af332ec8c2b70980fe3ad515d5733251e1a1d3924d9b2be0faa1295f3905e18dca63e522a3f2de3f72ca7d
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
- not_done = if exclude_end?
35
- ->(nxt) { nxt < self.end }
36
- else
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
- nxt = self.begin
49
+ y << last = self.begin
42
50
 
43
- while not_done.call(nxt) do
44
- y << nxt
45
-
46
- nxt += step
51
+ (count-1).times do
52
+ y << last = last + step
47
53
  end
48
54
  end
49
55
  end
@@ -1,3 +1,3 @@
1
1
  module Timerage
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
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.0
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-01 00:00:00.000000000 Z
12
+ date: 2014-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler