Skip to content

Commit e52fdb7

Browse files
committed
Improve PermissiveDateFormatter documentation
1 parent 4dbd6c7 commit e52fdb7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Sources/FeedKit/FeedDateFormatter.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class RFC3339DateFormatter: PermissiveDateFormatter, @unchecked Sendable {
103103
/// List of date formats supported for RFC3339.
104104
override var dateFormats: [String] {
105105
[
106+
// RFC 3339 without fractional seconds.
106107
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
108+
// RFC 3339 with 2-digit fractional seconds (limited precision).
107109
"yyyy-MM-dd'T'HH:mm:ss.SSZZZZZ",
108110
]
109111
}
@@ -125,19 +127,26 @@ class RFC822DateFormatter: PermissiveDateFormatter, @unchecked Sendable {
125127
/// List of date formats supported for RFC822.
126128
override var dateFormats: [String] {
127129
[
130+
// RFC 822/1123 format with seconds.
128131
"EEE, d MMM yyyy HH:mm:ss zzz",
132+
// RFC 822/1123 format without seconds.
129133
"EEE, d MMM yyyy HH:mm zzz",
130-
"d MMM yyyy HH:mm:ss Z",
131-
"yyyy-MM-dd HH:mm:ss Z",
134+
// RFC 822 compatible, includes day, month, year, time, and timezone.
135+
"d MMM yyyy HH:mm:ss zzz",
136+
// RFC 822 compatible, similar to above but without seconds.
137+
"d MMM yyyy HH:mm zzz",
138+
// RFC 822 compatible, includes weekday, day, month, year, time, and timezone.
139+
"EEE, dd MMM yyyy, HH:mm:ss zzz",
132140
]
133141
}
134142

135143
/// Backup date formats to handle potential parsing issues.
136144
override var permissiveDateFormats: [String] {
137145
[
138-
"d MMM yyyy HH:mm:ss zzz",
139-
"d MMM yyyy HH:mm zzz",
140-
"EEE, dd MMM yyyy, HH:mm:ss zzz",
146+
// Non-standard, similar to RFC 822 with numeric timezone.
147+
"d MMM yyyy HH:mm:ss Z",
148+
// Non-standard, ISO-like format with numeric timezone.
149+
"yyyy-MM-dd HH:mm:ss Z",
141150
]
142151
}
143152

0 commit comments

Comments
 (0)