BlinkID / blinkid-react-native

ID scanning for cross-platform apps built with ReactNative.
172 stars 59 forks source link

Date's returned for Passport and Drivers Licenses are not valid javascript dates #169

Closed kevinswartz closed 3 years ago

kevinswartz commented 3 years ago

Hi Guys, Thanks for your help with this library!

I'm seeing an issue with the dates I get back from scanning both passports and drivers licenses right now. I'm using blinkid-react-native v5.8.0. It looks to me that the months I get back are off by 1.

Here's a portion of a response for a Passport scan:

0: BlinkIdCombinedRecognizerResult
additionalAddressInformation: ""
additionalNameInformation: ""
address: ""
age: 37
backImageAnalysisResult: {barcodeDetectionStatus: 1, faceDetectionStatus: 1, blurred: false, mrzDetectionStatus: 1, documentImageColorStatus: 1}
backVizResult: {documentNumber: "", additionalPersonalIdNumber: "", religion: "", placeOfBirth: "", residentialStatus: "", …}
barcodeResult: {documentNumber: "", religion: "", residentialStatus: "", placeOfBirth: "", rawData: "", …}
classInfo: {type: 1, region: 1, country: 1}
dateOfBirth: Date {day: 31, month: 3, year: 1983}
dateOfExpiry: Date {day: 8, month: 8, year: 2024}

On the passport, I can see that the date of birth is indeed 3/31/1983. However months in Javascript are zero-based, so this date actually indicates 4/31/1983, which is not a valid date. This is a problem if I pass this date object into something like momentjs. I'm seeing this for dateOfBirth, and dateOfExpiry for US passports and Drivers Licenses.

i1E commented 3 years ago

Hi @kevinswartz,

Thank you for the report.

Our SDK returns this Date type, months start from value 1. January -> 1, February -> 2, ...

We will add this information to the Date type documentation.

You can prepare the month value (subtract 1), before sending it to the momentjs.

kevinswartz commented 3 years ago

Ok, thanks for the information! That is what I implemented. You might consider renaming your date object to something else to make this more obvious?