home_run 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +4 -0
  3. data/bench/cpu_bench.rb +2 -2
  4. data/lib/date.rb +55 -0
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e597260f47aed6dd34aa10985bd3b67469337a6
4
- data.tar.gz: 4fc4dbd96deefe7eb128d00fc4c7789a5b846ac4
3
+ metadata.gz: 533c0e16a73e050a9e72875e125e525aa95b53d3
4
+ data.tar.gz: da5e7fe1eb4ac76db19d043f409d967d376b1a34
5
5
  SHA512:
6
- metadata.gz: f1994eba1368cb26cc29fb812906098a6b3242134b80065430ab033bb1211aa946a9edcb9daffce10c26644cdc76a8a0759ac646cd4c14ad8aa30211461ea05e
7
- data.tar.gz: 323642badde2c9fa3d53b2e178ee5c820366c45a3be6c2c120911f9e2759cc4a56f95626e1daa7138e5f0784630efada56f00f603e32b3ec77c4892aeb2cb566
6
+ metadata.gz: 478219fef699a3e5132773132c4a66a19da0ef2d6400a015e6f1e9372ac58b5e0ad654b54f1f27c8c09e643728a7da17efff0077c5c7cee8756d1599eb9925bd
7
+ data.tar.gz: dc10c8ed3d992a4a87797491eaf55ad969fe02b8235a83c4fb7cf8b6b96de71dcb8d57fa47d19f9029221e1799fee8e74e5dfe38212af5a406cdde9b7fd19670
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.9 (2013-03-19)
2
+
3
+ * Add Date::Infinity implementation (jeremyevans) (#50)
4
+
1
5
  === 1.0.8 (2013-02-28)
2
6
 
3
7
  * Switch %i to %d in format strings to work on ruby 2.0 (jeremyevans)
@@ -7,7 +7,7 @@ compare(".commercial"){|dc| n.times{dc.commercial(2010, 1, 1)}}
7
7
  compare(".gregorian_leap?"){|dc| n.times{dc.gregorian_leap?(2000)}}
8
8
  compare(".jd"){|dc| n.times{dc.jd(2010)}}
9
9
  compare(".julian_leap?"){|dc| n.times{dc.julian_leap?(2000)}}
10
- compare(".new!"){|dc| n.times{dc.new!(2012)}}
10
+ compare(".new!"){|dc| n.times{dc.new!(2012)}} if RUBY_VERSION < '1.9.3'
11
11
  compare(".ordinal"){|dc| n.times{dc.ordinal(2012, 100)}}
12
12
  compare(".parse"){|dc| n.times{dc.parse('2010-12-13')}}
13
13
  compare(".strptime"){|dc| n.times{dc.strptime('fri jan 5 00:00:00 2007', '%c')}}
@@ -22,7 +22,7 @@ dt_compare("._strptime"){|dc| n.times{dc._strptime('fri jan 5 13:43:37 2007', '%
22
22
  dt_compare(".civil"){|dc| n.times{dc.civil(2010, 1, 1, 13, 43, 57)}}
23
23
  dt_compare(".commercial"){|dc| n.times{dc.commercial(2010, 1, 1, 13, 43, 57)}}
24
24
  dt_compare(".jd"){|dc| n.times{dc.jd(2010, 13, 43, 57)}}
25
- dt_compare(".new!"){|dc| n.times{dc.new!(201013.3, -8/24.0)}}
25
+ dt_compare(".new!"){|dc| n.times{dc.new!(201013.3, -8/24.0)}} if RUBY_VERSION < '1.9.3'
26
26
  dt_compare(".now"){|dc| n.times{dc.now}}
27
27
  dt_compare(".ordinal"){|dc| n.times{dc.ordinal(2010, 1, 13, 43, 57)}}
28
28
  dt_compare(".parse"){|dc| n.times{dc.parse('2010-12-13T13:43:57+08:00')}}
@@ -4,4 +4,59 @@ rescue LoadError
4
4
  raise unless RUBY_PLATFORM =~ /mswin|mingw/
5
5
  require "#{RUBY_VERSION[0...3]}/date_ext"
6
6
  end
7
+
8
+ class Date
9
+ class Infinity < Numeric # :nodoc:
10
+
11
+ include Comparable
12
+
13
+ def initialize(d=1) @d = d <=> 0 end
14
+
15
+ def d() @d end
16
+
17
+ protected :d
18
+
19
+ def zero? () false end
20
+ def finite? () false end
21
+ def infinite? () d.nonzero? end
22
+ def nan? () d.zero? end
23
+
24
+ def abs() self.class.new end
25
+
26
+ def -@ () self.class.new(-d) end
27
+ def +@ () self.class.new(+d) end
28
+
29
+ def <=> (other)
30
+ case other
31
+ when Infinity; return d <=> other.d
32
+ when Numeric; return d
33
+ else
34
+ begin
35
+ l, r = other.coerce(self)
36
+ return l <=> r
37
+ rescue NoMethodError
38
+ end
39
+ end
40
+ nil
41
+ end
42
+
43
+ def coerce(other)
44
+ case other
45
+ when Numeric; return -d, d
46
+ else
47
+ super
48
+ end
49
+ end
50
+
51
+ def to_f
52
+ return 0 if @d == 0
53
+ if @d > 0
54
+ Float::INFINITY
55
+ else
56
+ -Float::INFINITY
57
+ end
58
+ end
59
+ end
60
+ end
61
+
7
62
  require "date/format" unless defined?(Date::Format::ZONES)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: home_run
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-28 00:00:00.000000000 Z
11
+ date: 2013-03-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  home_run is an implementation of ruby's Date/DateTime classes in C,