From: Robert Dober Date: 2006-10-27T06:20:44+09:00 Subject: Re: Creating a Schedule-like array ------=_Part_61098_21288845.1161897643185 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/26/06, ara.t.howard@noaa.gov wrote: > > On Fri, 27 Oct 2006, anthony.green@bbc.co.uk wrote: > > >> Another way to compute timeslots which avoids this might be: > >> > >> timeslots = (0..6*24).map {|h| first + h.hour} > >> > >> Generalizing this to arbitray start and end times is left as an > >> exercise to the reader. > > > > Maybe this ? so you represent day segments > > > > start_time = Time.gm(2006, 10, 31, 0, 0, 0) > > slots = 3 > > no_of_days = 3 > > > > schedule =[] > > timeslots = (0..slots).map{|h| start_time + h.hour} > > timeslots.each do |timeslot| > > (0..no_of_days).map do |i| > > schedule << timeslot+i.day > > end > > end > > puts schedule > > > > Tony > > http://runt.rubyforge.org/ I remember very well when someone bashed me because I reported a broken link, I am still wondering why, anyway Ara is the link ok, I can go to rubyforge but not to runt, or was that "rant" ;) R. -a > -- > my religion is very simple. my religion is kindness. -- the dalai lama > > -- The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. - George Bernard Shaw ------=_Part_61098_21288845.1161897643185--