@@ -48,32 +48,14 @@ public struct ISO8601Coding: Decodable {
48
48
if #available( macOS 10 . 12 , * ) {
49
49
return Self . dateFormatter. date ( from: string)
50
50
} else {
51
- return self . decodeISO8601Date ( from: string) . flatMap ( Date . init ( timeIntervalSince1970: ) )
51
+ // unlikely *debugging* use case of swift 5.2+ on older macOS
52
+ preconditionFailure ( " Unsporrted macOS version " )
52
53
}
53
54
#endif
54
55
}
55
56
56
57
@available ( macOS 10 . 12 , * )
57
58
private static let dateFormatter = ISO8601DateFormatter ( )
58
-
59
- // strptime not avail on through Glibc
60
- #if os(macOS)
61
- // 1970-01-01T00:00:00Z
62
- internal static func decodeISO8601Date( from string: String ) -> Double ? {
63
- if string. last != " Z " {
64
- return nil
65
- }
66
- var parsedTime = tm ( )
67
- _ = string. withCString { cstr in
68
- strptime ( cstr, " %Y-%m-%dT%H:%M:%S " , & parsedTime)
69
- }
70
- let time = timegm ( & parsedTime)
71
- if time == - 1 {
72
- return nil
73
- }
74
- return Double ( time)
75
- }
76
- #endif
77
59
}
78
60
79
61
@propertyWrapper
@@ -101,7 +83,8 @@ public struct ISO8601WithFractionalSecondsCoding: Decodable {
101
83
if #available( macOS 10 . 13 , * ) {
102
84
return self . dateFormatter. date ( from: string)
103
85
} else {
104
- return self . decodeISO8601Date ( from: string) . flatMap ( Date . init ( timeIntervalSince1970: ) )
86
+ // unlikely *debugging* use case of swift 5.2+ on older macOS
87
+ preconditionFailure ( " Unsporrted macOS version " )
105
88
}
106
89
#endif
107
90
}
@@ -121,28 +104,6 @@ public struct ISO8601WithFractionalSecondsCoding: Decodable {
121
104
]
122
105
return formatter
123
106
}
124
-
125
- // strptime not avail on through Glibc
126
- #if os(macOS)
127
- // 1970-01-01T00:00:00.00Z
128
- internal static func decodeISO8601Date( from string: String ) -> Double ? {
129
- guard let msIndex = string. lastIndex ( of: " . " ) else {
130
- return nil
131
- }
132
- guard let endIndex = string. lastIndex ( of: " Z " ) else {
133
- return nil
134
- }
135
- if endIndex <= msIndex {
136
- return nil
137
- }
138
- let msString = string [ msIndex ..< endIndex]
139
- guard let ms = Double ( msString) else {
140
- return nil
141
- }
142
-
143
- return ISO8601Coding . decodeISO8601Date ( from: string) ? . advanced ( by: ms)
144
- }
145
- #endif
146
107
}
147
108
148
109
@propertyWrapper
0 commit comments