File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -260,12 +260,21 @@ final class JSONDecoderImpl: Decoder {
260260 return Date ( timeIntervalSince1970: double / 1000.0 )
261261 case . iso8601:
262262 let string = try unboxString ( from: value, for: codingPathNode, additionalKey)
263+ #if os(Linux)
264+ guard let date = try ? Date . ISO8601FormatStyle ( ) . parse ( string) else {
265+ throw DecodingError . dataCorrupted ( . init(
266+ codingPath: codingPathNode. path ( byAppending: additionalKey) ,
267+ debugDescription: " Expected date string to be ISO8601-formatted. "
268+ ) )
269+ }
270+ #else
263271 guard let date = _iso8601Formatter. date ( from: string) else {
264272 throw DecodingError . dataCorrupted ( . init(
265273 codingPath: codingPathNode. path ( byAppending: additionalKey) ,
266274 debugDescription: " Expected date string to be ISO8601-formatted. "
267275 ) )
268276 }
277+ #endif
269278 return date
270279 case . formatted( let formatter) :
271280 let string = try unboxString ( from: value, for: codingPathNode, additionalKey)
Original file line number Diff line number Diff line change @@ -146,13 +146,7 @@ extension Optional {
146146 }
147147}
148148
149- #if os(Linux)
150- nonisolated ( unsafe) let _iso8601Formatter : ISO8601DateFormatter = {
151- let formatter = ISO8601DateFormatter ( )
152- formatter. formatOptions = . withInternetDateTime
153- return formatter
154- } ( )
155- #else
149+ #if !os(Linux)
156150nonisolated ( unsafe) let _iso8601Formatter : JJLISO8601DateFormatter = {
157151 let formatter = JJLISO8601DateFormatter ( )
158152 formatter. formatOptions = . withInternetDateTime
You can’t perform that action at this time.
0 commit comments