diff --git a/Sources/IkigaJSON/Codable/JSONDecoder.swift b/Sources/IkigaJSON/Codable/JSONDecoder.swift index cc4f02e..1281234 100644 --- a/Sources/IkigaJSON/Codable/JSONDecoder.swift +++ b/Sources/IkigaJSON/Codable/JSONDecoder.swift @@ -262,6 +262,7 @@ fileprivate struct _JSONDecoder: Decoder { let string = try singleValueContainer().decode(String.self) return try date(from: string) as! D + #if !canImport(FoundationEssentials) || swift(<5.10) case .formatted(let formatter): let string = try singleValueContainer().decode(String.self) @@ -270,6 +271,7 @@ fileprivate struct _JSONDecoder: Decoder { } return date as! D + #endif case .custom(let makeDate): return try makeDate(self) as! D @unknown default: diff --git a/Sources/IkigaJSON/Codable/JSONEncoder.swift b/Sources/IkigaJSON/Codable/JSONEncoder.swift index 591eb36..1a6d2d0 100644 --- a/Sources/IkigaJSON/Codable/JSONEncoder.swift +++ b/Sources/IkigaJSON/Codable/JSONEncoder.swift @@ -386,12 +386,14 @@ fileprivate final class _JSONEncoder: Encoder { key.map { writeKey($0) } writeValue(string) + #if !canImport(FoundationEssentials) || swift(<5.10) case .formatted(let formatter): let string = formatter.string(from: date) if let key = key { writeKey(key) } writeValue(string) + #endif case .custom(let custom): let offsetBeforeKey = offset, hadWrittenValue = didWriteValue if let key = key {