From: Wilson Bilkovich Date: 2006-10-19T07:09:55+09:00 Subject: Re: too complex for me... On 10/18/06, Josselin wrote: > I need help from a ruby master... it's too hard with my present > understanding, any starting key will be apprciated .... > > from a period range [start_date, end_date] in ayear , I need to > produce a list of special days like the following : > ["2006-10-12","2006-11-08"] => { 10 : [ 12 , 31], 11 : [ 1, 8] } > or > ["2006-10-12","2006-12-08"] => { 10 : [ 12 , 31], 11 : [ 1, 30] , 12 > : [ 1, 12] } > which means, for each month in the range > the month number : [ period covered in the month] , > > where 'period covered in the month' is > [ 1st day of the period or 1st day of the month , last day of the > period or last day of the month ] > > coudl I get any clue ? > The first step, I would say, should be to convert your values from strings into real Date objects. require 'date' d1 = Date.new 2006, 10, 12 d2 = Date.new 2006, 12, 8 date_range = (d1..d2) date_range.each do |date| puts date end You can then collect up the months and days into whatever format you're looking for.