A possible solution...

It clearly shows every step in the process. Usually, the 5
lines within the loop are reduced to 1 or 2 lines, but you'll
end up with less readable code.
Not a good idea for newbies... ;]

Notice that it isn't very efficient when handling very long
periods.

gegroet,
Erik V. - http://www.erikveen.dds.nl/

----------------------------------------------------------------

 require "date"

 start   = Date.parse(ARGV.shift)
 finish  = Date.parse(ARGV.shift)
 hash    = {}

 (start..finish).each do |date|
   month         = [date.year, date.month]
   days          = hash[month] || []
   first_day     = days.shift || date.day
   last_day      = date.day
   hash[month]   = [first_day, last_day]
 end

 p start.to_s
 p finish.to_s
 p hash

----------------------------------------------------------------