interpreted_date 0.0.6 → 0.0.7

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.
@@ -1,3 +1,3 @@
1
1
  class InterpretedDate
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "interpreted_date/version"
2
+ require 'date'
2
3
 
3
4
  class InterpretedDate
4
5
  attr_accessor :decade, :year, :month, :day
@@ -134,10 +135,10 @@ class InterpretedDate
134
135
 
135
136
  def <=>(other_date)
136
137
  return nil unless other_date.is_a?(InterpretedDate)
137
- (self.decade <=> other_date.decade).nonzero? ||
138
- (self.year <=> other_date.year).nonzero? ||
139
- (self.month <=> other_date.month).nonzero? ||
140
- (self.day <=> other_date.day).nonzero? ||
138
+ (self.decade.to_i <=> other_date.decade.to_i).nonzero? ||
139
+ (self.year.to_i <=> other_date.year.to_i).nonzero? ||
140
+ (self.month.to_i <=> other_date.month.to_i).nonzero? ||
141
+ (self.day.to_i <=> other_date.day.to_i).nonzero? ||
141
142
  0
142
143
  end
143
144
 
@@ -150,6 +150,11 @@ describe InterpretedDate do
150
150
  (InterpretedDate.new({:decade => 2010, :year => 2012, :month => 3}) <=> InterpretedDate.new({:decade => 2010, :year => 2012, :month => 3})).should == 0
151
151
  end
152
152
 
153
+ it "correctly sorts with the month nil" do
154
+ (InterpretedDate.new({:decade => 2010, :year => 2012, :month => 2}) <=>
155
+ InterpretedDate.new({:decade => 2010, :year => 2012, :month => nil})).should == 1
156
+ end
157
+
153
158
  it "correctly sorts with the day" do
154
159
  (InterpretedDate.new({:decade => 2010, :year => 2012, :month => 2, :day => 31}) <=> InterpretedDate.new({:decade => 2010, :year => 2011, :month => 2, :day => 1 })).should == 1
155
160
  (InterpretedDate.new({:decade => 2010, :year => 2012, :month => 2, :day => 15}) <=> InterpretedDate.new({:decade => 2010, :year => 2013, :month => 2, :day => 31 })).should == -1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interpreted_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec