From a4b1c0e27fb70f4a096659cff5ac953e5f245b97 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Fri, 27 Mar 2026 17:44:13 +0100 Subject: [PATCH] Addressed a ISO date+time decoding issue inside the "decode(_:)" method for the ISOTimestampTranscoder transcoder in the library target. --- .../Transcoders/ISOTimestampTranscoder.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/AmiiboService/Internal/Transcoders/ISOTimestampTranscoder.swift b/Sources/AmiiboService/Internal/Transcoders/ISOTimestampTranscoder.swift index d1d1011..0a2121a 100644 --- a/Sources/AmiiboService/Internal/Transcoders/ISOTimestampTranscoder.swift +++ b/Sources/AmiiboService/Internal/Transcoders/ISOTimestampTranscoder.swift @@ -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 } }