Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with case .formatted of DateFormatter on Linux (swift 6) #43

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading