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 } }