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.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/bench/cpu_bench.rb +2 -2
- data/lib/date.rb +55 -0
- 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: 533c0e16a73e050a9e72875e125e525aa95b53d3
|
4
|
+
data.tar.gz: da5e7fe1eb4ac76db19d043f409d967d376b1a34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 478219fef699a3e5132773132c4a66a19da0ef2d6400a015e6f1e9372ac58b5e0ad654b54f1f27c8c09e643728a7da17efff0077c5c7cee8756d1599eb9925bd
|
7
|
+
data.tar.gz: dc10c8ed3d992a4a87797491eaf55ad969fe02b8235a83c4fb7cf8b6b96de71dcb8d57fa47d19f9029221e1799fee8e74e5dfe38212af5a406cdde9b7fd19670
|
data/CHANGELOG
CHANGED
data/bench/cpu_bench.rb
CHANGED
@@ -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')}}
|
data/lib/date.rb
CHANGED
@@ -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.
|
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-
|
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,
|