Replace QString::mid with base::StringViewMid where QStringView is accepted

This commit is contained in:
Ilya Fedin 2023-12-22 03:52:07 +04:00 committed by John Preston
parent 0d72d47318
commit f3bda59019

View file

@ -235,7 +235,7 @@ ExpireDateValidationResult ValidateExpireDate(
return { ValidationState::Incomplete };
}
const auto normalized = (sanitized[0] > '1' ? "0" : "") + sanitized;
const auto month = normalized.mid(0, 2).toInt();
const auto month = base::StringViewMid(normalized, 0, 2).toInt();
if (month < 1 || month > 12) {
return { ValidationState::Invalid };
} else if (normalized.size() < 4) {
@ -243,7 +243,7 @@ ExpireDateValidationResult ValidateExpireDate(
} else if (normalized.size() > 4) {
return { ValidationState::Invalid };
}
const auto year = 2000 + normalized.mid(2).toInt();
const auto year = 2000 + base::StringViewMid(normalized, 2).toInt();
const auto thresholdDate = overrideExpireDateThreshold.value_or(
QDate::currentDate());