Created
December 31, 2011 20:18
-
-
Save agilous/1545224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'date' | |
def months_between(start, stop) | |
diff = (stop - start) | |
(diff/30).floor.to_i + (diff % 30 > 15 ? 1 : 0) | |
end | |
(0..12).each do |i| | |
(0..100).each do |j| | |
start = Date.new(2011,12,1) >> i | |
stop = (start >> 2) + 1 | |
start = start + j | |
puts "There are #{months_between(start,stop)} months between dates #{stop - start} days apart." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment