Tuesday, June 26, 2012

How to create two-dimensional array of Date class for each months (1)

How to create two-dimensional array of Date class for each months:
require 'date'
begin_day = Date.new(2012, 4, 1)
end_day = Date.new(2012, 6, -1)
hash_each_month = (begin_day..end_day).group_by(&:month) # hash
days_each_month = (begin_day..end_day).group_by(&:month).values # two-dimensional array

(continue to phosphorescence: How to create two-dimensional array of Date class for each months (2))

No comments:

Post a Comment