title: Iterating between two DateTimes, with a one hour step
body: <p>I'm looking for an efficient way, in Ruby 1.9.x/Rails 3.2.x, to iterate between two DateTime objects, with a one-hour step.</p>
  
  <pre><code>('2013-01-01'.to_datetime .. '2013-02-01'.to_datetime).step(1.hour) do |date|
     ...
  end
  </code></pre>
  
  <p>I understand that an issue with this is that <code>1.hour</code> is just the number of seconds, but my attempts to convert that to a DateTime object and use that as the step doesn't work either.</p>
  
  <p>I looked at "<a href="http://alindeman.github.com/2011/01/22/beware-of-ruby-syntactic-sugar.html" rel="noreferrer">Beware of Ruby Sugar</a>". It mentions, near the bottom, that DateTime has a direct <code>step</code> method. I confirmed this by running <code>methods</code> on a DateTime object, but I cannot find any documentation on <code>step</code> in DateTime, in either Ruby's or Rails' documents.</p>