Jump to content

Ruby midpoint between two dates

From EggeWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

I needed to find the midpoint between to dates. Unfortunately, I didn't have my HP12C handy, so I executed calculated the same in ruby.

<geshi lang="ruby"> require 'date' => true (Date.new(2009,07, 01) - Date.new(2009, 04, 01)).to_i => 91 (Date.new(2009, 04, 01) + 45).to_s => "2009-05-16" </geshi>