Sunday 18 February 2018

FInd months and weeks between two date range OR Add array index to each other

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

Revert last commit or second last and more....

 Git revert commit_id -m 1 this command willl revert last commit  Git revert commit_id -m 2 this command will revert second commit with same...