Skip to content

Commit

Permalink
Merge pull request #43 from Kishimotovn/master
Browse files Browse the repository at this point in the history
Fixed issue with case .formatted of DateFormatter on Linux (swift 6)
  • Loading branch information
Joannis authored Sep 30, 2024
2 parents 9f10155 + f9d60bd commit e5144e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/IkigaJSON/Codable/JSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Sources/IkigaJSON/Codable/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e5144e9

Please sign in to comment.