Created
October 23, 2013 15:57
-
-
Save ma11hew28/7121365 to your computer and use it in GitHub Desktop.
Calculate birthdate range from dates & ages.
This file contains hidden or 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
# Census Birthdate Calculator | |
# http://sean.famthings.com/2009/03/04/the-census-birth-date-calculator/ | |
# http://genealogy.eshea.us/anchestor_birthdate_calculator.html | |
# Calculate birthdate range from dates & ages. | |
# Usage: ruby census_birthdate_calculator.rb 2000-04-14 16 2013-03-21 28 | |
require 'date' | |
birthdate_starts = [] | |
birthdate_ends = [] | |
ARGV.each_slice(2) do |date, age| | |
date = Date.parse(date) | |
age = age.to_i | |
birthdate_starts << (date.prev_year(age+1)+1) | |
birthdate_ends << date.prev_year(age) | |
end | |
puts "Birthday Range: #{birthdate_starts.max} - #{birthdate_ends.min}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment