require 'date'
months = (Date.parse("2014-01-30")..Date.parse("2014-03-27")).group_by(&:month).map { |_,v| v.first.end_of_month.to_s }
# => ["2014-01-31", "2014-02-28", "2014-03-31"]
weeks = (Date.parse("2014-01-30")..Date.parse("2014-03-27")).select(&:sunday?).map(&:to_s)
Add Array index with Value
[[1,2,3], [4,5,6]].transpose.map {|x| x.reduce(:+)}
No comments:
Post a Comment