zoneless_time 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,15 +10,15 @@ module ZonelessTime
10
10
  end
11
11
 
12
12
  def <=>(other)
13
- to_i <=> other.to_i
13
+ to_i <=> other.to_time.to_i
14
14
  end
15
15
 
16
16
  def >(other)
17
- to_i > other.to_i
17
+ to_i > other.to_time.to_i
18
18
  end
19
19
 
20
20
  def <(other)
21
- to_i < other.to_i
21
+ to_i < other.to_time.to_i
22
22
  end
23
23
 
24
24
  def +(amount)
@@ -34,6 +34,14 @@ module ZonelessTime
34
34
  (result.is_a? Time) ? result.without_zone : result
35
35
  end
36
36
 
37
+ def since(amount)
38
+ self + amount
39
+ end
40
+
41
+ def until(amount)
42
+ self - amount
43
+ end
44
+
37
45
  def initialize(year,month,day,hour,min,sec,usec=0)
38
46
  @date = Date.new(year,month,day)
39
47
  @hour = hour
@@ -75,6 +83,10 @@ module ZonelessTime
75
83
  to_time.to_i
76
84
  end
77
85
 
86
+ def hash
87
+ self.class.hash ^ to_i
88
+ end
89
+
78
90
  def without_zone
79
91
  dup
80
92
  end
@@ -107,6 +119,10 @@ module ZonelessTime
107
119
  matches? other
108
120
  end
109
121
 
122
+ def eql?(other)
123
+ self == other
124
+ end
125
+
110
126
  def acts_like?(sym)
111
127
  [:date, :time].include? sym
112
128
  end
@@ -118,7 +134,9 @@ module ZonelessTime
118
134
 
119
135
  class <<self
120
136
  def at(time)
121
- if time.is_a? self
137
+ if time.nil?
138
+ nil
139
+ elsif time.is_a? self
122
140
  time
123
141
  elsif time.acts_like? :time
124
142
  from_time time
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoneless_time
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- version: "0.3"
9
+ - 1
10
+ version: 0.3.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Shaun Mangelsdorf
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-08-10 00:00:00 Z
18
+ date: 2011-08-12 00:00:00 Z
18
19
  dependencies: []
19
20
 
20
21
  description: