Project

General

Profile

RE: convert monthly averages to monthly totals ยป m2s.rb

Ralf Mueller, 2019-11-07 11:07

 
require 'time'
years = (2001..2009)
months = (1..12)

years.each {|year|
months.each {|month|

dateStart = DateTime.new(year,month,1,0,0,0)
if 12 != month then
dateEnd = DateTime.new(year,month+1,1,0,0,0)
else
dateEnd = DateTime.new(year+1,1,1,0,0,0)
end

diffInSeconds = dateEnd.strftime('%s').to_i - dateStart.strftime('%s').to_i
pp [diffInSeconds, dateStart.to_s, dateEnd.to_s]
}
}


    (1-1/1)