Skip to content
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/ReerJSON/JSONDecoderImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ final class JSONDecoderImpl: Decoder {
))
}
return date
#if !os(Linux)
case .formatted(let formatter):
let string = try unboxString(from: value, for: codingPathNode, additionalKey)
guard let date = formatter.date(from: string) else {
Expand All @@ -276,6 +277,7 @@ final class JSONDecoderImpl: Decoder {
))
}
return date
#endif
case .custom(let closure):
return try with(value: value, path: codingPathNode.appending(additionalKey)) {
try closure(self)
Expand Down
2 changes: 2 additions & 0 deletions Sources/ReerJSON/JSONEncoderImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ class JSONEncoderImpl: Encoder {
return try wrapFloat(1000.0 * date.timeIntervalSince1970, for: additionalKey)
case .iso8601:
return wrapString(_iso8601Formatter.string(from: date))
#if !os(Linux)
case .formatted(let formatter):
return wrapString(formatter.string(from: date))
#endif
case .custom(let closure):
return try _encodeNestedValue(for: additionalKey) { try closure(date, self) } ?? yyjson_mut_obj(doc)
@unknown default: fatalError()
Expand Down