mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-04 03:08:43 +00:00
Fix bug where the year could be taken as the day.
This commit is contained in:
1 parent
c51c13a3d4
commit
ec7ea1713f
2 files changed
+8
No files matched your search
@@ -41,6 +41,8 @@ public enum DateParser {
|
||||
return parseW3CDate(slice)
|
||||
}
|
||||
|
||||
private static let maxDayDigits = 2
|
||||
|
||||
// MARK: - Month table
|
||||
//
|
||||
// First three letters of each month name, packed like the time zone keys below.
|
||||
@@ -243,9 +245,13 @@ private extension DateParser {
|
||||
}
|
||||
|
||||
// Skip the day, an ordinal suffix (`th`), and separators: the year must come next.
|
||||
let dayStart = i
|
||||
while i < slice.endIndex && isDigit(slice[i]) {
|
||||
i += 1
|
||||
}
|
||||
guard i - dayStart <= maxDayDigits else {
|
||||
return nil
|
||||
}
|
||||
while i < slice.endIndex && isAlpha(slice[i]) {
|
||||
i += 1
|
||||
}
|
||||
|
||||
@@ -153,6 +153,8 @@ import Testing
|
||||
assertNilResult("25 Nov 10:00")
|
||||
assertNilResult("Fri Nov 27 14:07:36 PST 2026")
|
||||
assertNilResult("Fri, Nov 2026")
|
||||
// The year isn't taken as the day.
|
||||
assertNilResult("Nov 2026 10:00:00 GMT")
|
||||
}
|
||||
|
||||
@Test func fourDigitYearFollowedByColon() {
|
||||
|
||||
Reference in new issue
Block a user