Skip to content

Commit 6e217c4

Browse files
committed
force birthdate to be in the past
1 parent b10a4c8 commit 6e217c4

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

PassportScanner.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Pod::Spec.new do |s|
88
#
99

1010
s.name = "PassportScanner"
11-
s.version = "4.0.1"
11+
s.version = "4.3.0"
1212
s.summary = "Scan the MRZ code on a passport"
1313

1414
s.description = "Scan the MRZ code on a passport and it's data'"

PassportScanner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
TargetAttributes = {
185185
7F132F2D1B9ED2C5001A542A = {
186186
CreatedOnToolsVersion = 6.4;
187-
DevelopmentTeam = Q6FGJYQPM4;
187+
DevelopmentTeam = 6Z7QY98HTS;
188188
LastSwiftMigration = 0800;
189189
};
190190
};
@@ -402,7 +402,7 @@
402402
buildSettings = {
403403
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
404404
CLANG_ENABLE_MODULES = YES;
405-
DEVELOPMENT_TEAM = Q6FGJYQPM4;
405+
DEVELOPMENT_TEAM = 6Z7QY98HTS;
406406
ENABLE_BITCODE = NO;
407407
INFOPLIST_FILE = PassportScanner/Info.plist;
408408
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -425,7 +425,7 @@
425425
buildSettings = {
426426
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
427427
CLANG_ENABLE_MODULES = YES;
428-
DEVELOPMENT_TEAM = Q6FGJYQPM4;
428+
DEVELOPMENT_TEAM = 6Z7QY98HTS;
429429
ENABLE_BITCODE = NO;
430430
INFOPLIST_FILE = PassportScanner/Info.plist;
431431
IPHONEOS_DEPLOYMENT_TARGET = 8.0;

Pod/MRZParser.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ open class MRZParser : NSObject{
3232

3333
:param: value The string value that needs to be converted to a date
3434

35-
:returns: Returns the date value for the string
35+
:returns: Returns the date value for the string and force it to be in the past
3636
*/
37-
class func dateFromString(_ value: String) -> Date? {
37+
class func dateFromString(_ value: String, inThePast: Bool = false) -> Date? {
3838
var date: Date?
3939
let dateStringFormatter = DateFormatter()
4040
dateStringFormatter.dateFormat = "YYMMdd"
4141
dateStringFormatter.locale = Locale(identifier: "en_US_POSIX")
4242
let d = dateStringFormatter.date(from: value)
4343
if d != nil {
44-
date = Date(timeInterval:0, since:d!)
44+
date = Date(timeInterval: 0, since: d!)
45+
}
46+
if let dateU = date, dateU > Date(), inThePast {
47+
date = Calendar.current.date(byAdding: .year, value: -100, to: dateU)
4548
}
4649
return date
4750
}

Pod/MRZTD1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ open class MRZTD1: MRZParser {
179179
// Line 2 parsing
180180
let birth = line2.subString(0, to: 5).toNumber()
181181
let birthValidation = line2.subString(6, to: 6).toNumber()
182-
dateOfBirth = MRZTD1.dateFromString(birth)
182+
dateOfBirth = MRZTD1.dateFromString(birth, inThePast: false)
183183
debugLog("date of birth : \(dateOfBirth)")
184184
sex = line2.subString(7, to: 7)
185185
debugLog("sex : \(sex)")

Pod/MRZTD3.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ open class MRZTD3: MRZParser {
164164
debugLog("nationality : \(nationality)")
165165
let birth = line2.subString(13, to: 18).toNumber()
166166
let birthValidation = line2.subString(19, to: 19).toNumber()
167-
dateOfBirth = MRZTD3.dateFromString(birth)
167+
dateOfBirth = MRZTD3.dateFromString(birth, inThePast: true)
168168
debugLog("date of birth : \(dateOfBirth)")
169169
sex = line2.subString(20, to: 20)
170170
debugLog("sex : \(sex)")

0 commit comments

Comments
 (0)