Addressed a ISO date+time decoding issue inside the "decode(_:)" method for the ISOTimestampTranscoder transcoder in the library target.

This commit is contained in:
2026-03-27 17:44:13 +01:00
parent 255350ba3a
commit a4b1c0e27f
@@ -40,9 +40,17 @@ extension ISOTimestampTranscoder: DateTranscoder {
/// Decodes an ISO timestamp string into a date.
/// - Parameter string: A string to decode.
/// - Returns: A date parsed from the string, or the Unix epoch if the string cannot be parsed.
/// - Returns: A date parsed from the string.
/// - Throws: A `DecodingError` if the string cannot be parsed into a valid date.
func decode(_ string: String) throws -> Date {
dateFormatter.date(from: string) ?? .init()
guard let date = dateFormatter.date(from: string) else {
throw DecodingError.dataCorrupted(.init(
codingPath: [],
debugDescription: "Expected an ISO timestamp with format 'yyyy-MM-dd'T'HH:mm:ss.SSSSSS', but found '\(string)' instead."
))
}
return date
}
}