require "date" module MRZ class YYDate def convert_to_date(input_date) #yymmdd has the flaw of not knowing which century #uses current year as a cut off to make an accurate prediction current_year_yy = (Date.today.strftime("%Y"))[2..4] input_year_yy = input_date[0..1] input_month = input_date[2..3] input_day = input_date[4..5] begin return Date.parse(input_day+"-"+input_month+"-"+"19"+input_year_yy) if input_year_yy >= current_year_yy rescue return false end begin return Date.parse(input_day+"-"+input_month+"-"+"20"+input_year_yy) rescue return false end end end end