Skip to content

Commit

Permalink
Fixes for code review
Browse files Browse the repository at this point in the history
Co-authored-by: Roman Mazeev <[email protected]>
  • Loading branch information
magauran and Roman Mazeev authored Sep 25, 2021
1 parent 8d0856d commit 35ccd2c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/MRZParser/Private/MRZField/MRZFieldFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct MRZFieldFormatter {
let parsedYear = Int(string.substring(0, to: 1)) else { return nil }
let currentYear = Calendar.current.component(.year, from: Date()) - Self.currentCentennial * 100
let boundaryYear = currentYear + 50
let centennial = (parsedYear >= boundaryYear) ? String(Self.previousCentennial) : String(Self.currentCentennial)
let centennial = parsedYear >= boundaryYear ? String(Self.previousCentennial) : String(Self.currentCentennial)
return dateFormatter.date(from: centennial + string)
}

Expand All @@ -173,7 +173,7 @@ struct MRZFieldFormatter {
static func checkDigit(for value: String) -> Int? {
var sum: Int = 0
for (index, character) in value.enumerated() {
guard let number = Self.number(for: character) else { return nil }
guard let number = number(for: character) else { return nil }
let weights = [7, 3, 1]
sum += number * weights[index % 3]
}
Expand Down

0 comments on commit 35ccd2c

Please sign in to comment.