Skip to content

Instantly share code, notes, and snippets.

@ma11hew28
Created October 23, 2013 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ma11hew28/7121365 to your computer and use it in GitHub Desktop.
Save ma11hew28/7121365 to your computer and use it in GitHub Desktop.
Calculate birthdate range from dates & ages.
# 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