array = [2007, 2008, 2009, 2010]
quarters = []
array.each do |a|
date = Date.parse("1.1.#{a}")
4.times do
quarters << [date, date+3.month-1.day]
date += 3.month
end
end
quarters
#=> [[Mon, 01 Jan 2007, Sat, 31 Mar 2007], [Sun, 01 Apr 2007, Sat, 30 Jun 2007], [Sun, 01 Jul 2007, Sun, 30 Sep 2007], [Mon, 01 Oct 2007, Mon, 31 Dec 2007], [Tue, 01 Jan 2008, Mon, 31 Mar 2008], [Tue, 01 Apr 2008, Mon, 30 Jun 2008], [Tue, 01 Jul 2008, Tue, 30 Sep 2008], [Wed, 01 Oct 2008, Wed, 31 Dec 2008], [Thu, 01 Jan 2009, Tue, 31 Mar 2009], [Wed, 01 Apr 2009, Tue, 30 Jun 2009], [Wed, 01 Jul 2009, Wed, 30 Sep 2009], [Thu, 01 Oct 2009, Thu, 31 Dec 2009], [Fri, 01 Jan 2010, Wed, 31 Mar 2010], [Thu, 01 Apr 2010, Wed, 30 Jun 2010], [Thu, 01 Jul 2010, Thu, 30 Sep 2010], [Fri, 01 Oct 2010, Fri, 31 Dec 2010]]