|
|
@@ -122,7 +122,6 @@ public class FirebaseDataEncoder {
|
|
|
case millisecondsSince1970
|
|
|
|
|
|
/// Encode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
|
|
|
- @available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
|
|
|
case iso8601
|
|
|
|
|
|
/// Encode the `Date` as a string formatted by the given formatter.
|
|
|
@@ -823,11 +822,7 @@ extension __JSONEncoder {
|
|
|
return NSNumber(value: 1000.0 * date.timeIntervalSince1970)
|
|
|
|
|
|
case .iso8601:
|
|
|
- if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
|
|
|
return NSString(string: _iso8601Formatter.string(from: date))
|
|
|
- } else {
|
|
|
- fatalError("ISO8601DateFormatter is unavailable on this platform.")
|
|
|
- }
|
|
|
|
|
|
case .formatted(let formatter):
|
|
|
return NSString(string: formatter.string(from: date))
|
|
|
@@ -1080,7 +1075,6 @@ public class FirebaseDataDecoder {
|
|
|
case millisecondsSince1970
|
|
|
|
|
|
/// Decode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
|
|
|
- @available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
|
|
|
case iso8601
|
|
|
|
|
|
/// Decode the `Date` as a string parsed by the given formatter.
|
|
|
@@ -2443,16 +2437,12 @@ extension __JSONDecoder {
|
|
|
return Date(timeIntervalSince1970: double / 1000.0)
|
|
|
|
|
|
case .iso8601:
|
|
|
- if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
|
|
|
let string = try self.unbox(value, as: String.self)!
|
|
|
guard let date = _iso8601Formatter.date(from: string) else {
|
|
|
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Expected date string to be ISO8601-formatted."))
|
|
|
}
|
|
|
|
|
|
return date
|
|
|
- } else {
|
|
|
- fatalError("ISO8601DateFormatter is unavailable on this platform.")
|
|
|
- }
|
|
|
|
|
|
case .formatted(let formatter):
|
|
|
let string = try self.unbox(value, as: String.self)!
|
|
|
@@ -2621,7 +2611,6 @@ fileprivate struct _JSONKey : CodingKey {
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
// NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled against the latest SDK (w/ ISO8601DateFormatter), but linked against whichever Foundation the user has. ISO8601DateFormatter might not exist, so we better not hit this code path on an older OS.
|
|
|
-@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
|
|
|
fileprivate var _iso8601Formatter: ISO8601DateFormatter = {
|
|
|
let formatter = ISO8601DateFormatter()
|
|
|
formatter.formatOptions = .withInternetDateTime
|