From: Eric Peterson Date: 2009-07-14T00:42:22+09:00 Subject: Re: calculating an array of dates Siep Korteling wrote: > > I have not looked into the reasons why your code doesn't work, just took > your post as a coding exercise. My try looks like this: > > require 'Date' > class Date > def thursdays_upto_now > end_date = Date.today > res = [] > # get the last thursday: > end_date -= 1 while (end_date.wday != 4) > end_date.step(self, -7) do |date| > res << date > end > res > end > end > > start_date = Date.parse( 'Thu Jun 11 13:14:44 -0700 2009' ) > start_date.thursdays_upto_now.each{|thursday| puts thursday.to_s} # or > whatever > > I was happy finding out Date has a step method. > > hth, I had some fun, > > Siep much better then my final code. I guess my mind is still stuck in FORTRAN method of coding. I'm finding Ruby very nice and interesting. Lots of new tricks to learn. Thanks Eric -- Posted via http://www.ruby-forum.com/.