From: Mikkel Bruun Date: 2008-03-03T17:05:08+09:00 Subject: Re: making a monthly calendar... So I ended up with: def calendar_view firstday = days[0] #all days in month offset = firstday.wday-1 boxes =Array.new(5*7) # the viewport i=0 #this month from wday of firstday offset.upto(days.length+offset){boxes[offset+i]=days[i];i=i+1} i=0 #pad with previous 1.upto(offset){boxes[i]=previous.days[-offset+i];i=i+1} i=0 #pad with next... (offset+days.length).upto(boxes.length){boxes[days.length+i+offset]=next_month.days[i];i=i+1} return boxes end I show this in a rails app using array.groups_of(7) which chops the boxes array into parts of 7 which works ok...untill i hit june 08....where the first week starts with jun 2nd... How are your algorithms working?? -- Posted via http://www.ruby-forum.com/.