Sha256: 88bbd4c18caaf6133c0a822b8465d1af5936c37d2173e8d85e71c1e35ee236ca

Contents?: true

Size: 571 Bytes

Versions: 2

Compression:

Stored size: 571 Bytes

Contents

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]
      return Date.parse(input_day+"-"+input_month+"-"+"19"+input_year_yy) if input_year_yy >= current_year_yy
      return Date.parse(input_day+"-"+input_month+"-"+"20"+input_year_yy)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
verified-1.3.1 lib/verified/parser/mrz/yy_date.rb
verified-1.3.0 lib/verified/parser/mrz/yy_date.rb