Ruby midpoint between two dates: Difference between revisions
m (Created page with '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' => tr…') |
mNo edit summary |
||
Line 8: | Line 8: | ||
(Date.new(2009, 04, 01) + 45).to_s | (Date.new(2009, 04, 01) + 45).to_s | ||
=> "2009-05-16" | => "2009-05-16" | ||
<geshi> | </geshi> | ||
[[Category:ruby]] | [[Category:ruby]] |
Latest revision as of 03:43, 10 July 2009
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>