Forum: Ruby iterative question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
joe (Guest)
on 2006-06-08 18:31
hi all
 how to do a iterative for Time object,
 i.e.
 i wanna  iterative from 2000/05/05 to now, output to a array

regards
Daniel S. (Guest)
on 2006-06-08 18:47
(Received via mailing list)
joe wrote:
>  how to do a iterative for Time object,
>  i.e.
>  i wanna  iterative from 2000/05/05 to now, output to a array

   (time_a..time_b).to_a


Daniel
Chris (Guest)
on 2006-06-08 18:56
joe wrote:
> hi all
>  how to do a iterative for Time object,
>  i.e.
>  i wanna  iterative from 2000/05/05 to now, output to a array
>
> regards

Date supports iteration:

startDate = Date.parse('2000/05/05')
days = []
startDate.upto(Date.today){|day| days << day}

cheers
This topic is locked and can not be replied to.