Skip to content

Commit 06e8dd3

Browse files
committed
reuse parse strategy
1 parent ef50f61 commit 06e8dd3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/AWSLambdaEvents/Utils/DateWrappers.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public struct ISO8601Coding: Decodable, Sendable {
4343
}
4444
}
4545

46-
47-
4846
private static func parseISO8601(dateString: String) throws -> Date {
4947
if #available(macOS 12.0, *) {
5048
return try Date(dateString, strategy: .iso8601)
@@ -141,9 +139,9 @@ public struct RFC5322DateTimeCoding: Decodable, Sendable {
141139

142140
do {
143141
if #available(macOS 12.0, *) {
144-
self.wrappedValue = try Date(string, strategy: RFC5322DateParseStrategy())
142+
self.wrappedValue = try Date(string, strategy: Self.rfc5322DateParseStrategy)
145143
} else {
146-
self.wrappedValue = try RFC5322DateParseStrategy().parse(string)
144+
self.wrappedValue = try Self.rfc5322DateParseStrategy.parse(string)
147145
}
148146
} catch {
149147
throw DecodingError.dataCorruptedError(
@@ -154,4 +152,6 @@ public struct RFC5322DateTimeCoding: Decodable, Sendable {
154152
}
155153
}
156154

157-
}
155+
private static let rfc5322DateParseStrategy = RFC5322DateParseStrategy(calendar: Calendar(identifier: .gregorian))
156+
157+
}

0 commit comments

Comments
 (0)