<p>I want to be able to compare Dates and Times in Rails without always having to call the to_time or to_date method. So I wrote the following code:</p>

<pre><code>class Date
  def ==(other)
    if other.kind_of?(Time)
      self.to_time == other
    else
      super(other)
    end
  end
end
</code></pre>

<p>I know there's an easy way to write this so that I can make this work for >, &lt;, >=, &lt;= and &lt;=>. But I forgot how :P Any ideas?</p>

Your example looks okay, but I wouldn't use
```
kind_of?
```
- if
```
other
```
doesn't implement
```
to_time
```
you get an exception anyway!
Update: What you are looking for is probably the
```
<=>
```
operator!