From: Daniel Finnie Date: 2008-03-01T08:08:22+09:00 Subject: Re: making a monthly calendar... ------=_Part_14598_5944895.1204326509088 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Something like this? daniel@daniel-desktop:~$ cat /tmp/dats.rb require 'date' start_date = Date.civil(2007, 1, 27) # Must be a Sunday. 0.upto(4 * 7 - 1) do |offset| # 4 weeks curr_date = start_date + offset print curr_date.mday.to_s.rjust(3) if offset % 7 == 6 puts end end puts daniel@daniel-desktop:~$ ruby /tmp/dats.rb 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 daniel@daniel-desktop:~$ The formatting is better if you run it at the command line. Dan On Fri, Feb 29, 2008 at 5:30 PM, Mikkel Bruun wrote: > Hey > > I trying to do a calendar based app.. > > So i have a monthly view with 5 weeks of 7 days = 35 boxes... > > Just like google calendar i need to show the selected month, and fill in > the blanks with the previous and next months days... > > so february is ending today on a friday. So in the last 2 boxes of the > 5. week i need to show march 1 and 2 and the same in the front... > > I have this Month class. Which contains all the dates for a given month, > as well as references to the next and previous months.... > > there must be some kind of pattern im not getting bevause i keep > slamming my head against the wall on this.... > > anyone who have a quuck solution??? > > thanks!! > > mikkel > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_14598_5944895.1204326509088--