DateTime Enumerator

Can someone explain this for me please?

range = (DateTime.now..DateTime.now+1.hour).step(10.minute)
=> #<Enumerator: Sat, 26 Sep 2015 16:41:18 +0100..Sat, 26 Sep 2015
17:41:18 +0100:step(600 seconds)>
2.1.3 :009 > range.to_a
=> [Sat, 26 Sep 2015 16:41:18 +0100]

Not what I expected at all.

Colin

hmm maybe relevant http://www.benknowscode.com/2014/02/ruby-date-time-range-intervals.html

hmm maybe relevant
http://www.benknowscode.com/2014/02/ruby-date-time-range-intervals.html

Thanks, if I interpret that correctly it is saying that what I am
trying to do just doesn't work, that it is a limitation of ruby. It
is not a big problem as there are other simple ways of achieving the
desired result.

Colin

> hmm maybe relevant
> http://www.benknowscode.com/2014/02/ruby-date-time-range-intervals.html

Thanks, if I interpret that correctly it is saying that what I am
trying to do just doesn't work, that it is a limitation of ruby. It
is not a big problem as there are other simple ways of achieving the
desired result.

Yeah looks like it. I vaguely remember encountering something like this
before
but I can't quite put my finger on what I needed back then. If you find a
way to
make it work using the step method, share it here :smiley: