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
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import PackageDescription
let package = Package(
name: "mongo-swift-driver",
platforms: [
.macOS(.v10_14)
],
products: [
.library(name: "MongoSwift", targets: ["MongoSwift"]),
.library(name: "MongoSwiftSync", targets: ["MongoSwiftSync"])
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) an
Core Server (i.e. SERVER) project are **public**.

## Installation
The driver supports use with Swift 5.1+ on MacOS and Linux.
The driver supports use with Swift 5.1+. The minimum macOS version required to build the driver is 10.14. The driver is tested in continuous integration against macOS 10.14, Ubuntu 16.04, and Ubuntu 18.04.

Installation is supported via [Swift Package Manager](https://swift.org/package-manager/).

Expand Down
3 changes: 0 additions & 3 deletions Sources/MongoSwift/BSON/BSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ extension _BSONDecoder {
let seconds = try unboxNumber(value, as: Double.self)
return Date(timeIntervalSince1970: seconds)
case .iso8601:
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
fatalError("ISO8601DateFormatter is unavailable on this platform.")
}
let isoString = try self.unboxCustom(value) { $0.stringValue }
guard let date = BSONDecoder.iso8601Formatter.date(from: isoString) else {
throw DecodingError.dataCorrupted(
Expand Down
3 changes: 0 additions & 3 deletions Sources/MongoSwift/BSON/BSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,6 @@ extension _BSONEncoder {
case let .formatted(formatter):
return formatter.string(from: date)
case .iso8601:
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
fatalError("ISO8601DateFormatter is unavailable on this platform.")
}
return BSONDecoder.iso8601Formatter.string(from: date)
case let .custom(f):
return try self.handleCustomStrategy(encodeFunc: f, forValue: date)
Expand Down
6 changes: 0 additions & 6 deletions Sources/MongoSwift/BSON/CodingStrategies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public enum DateCodingStrategy: RawRepresentable {
case (.secondsSince1970, .secondsSince1970):
self = .secondsSince1970
case (.iso8601, .iso8601):
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
fatalError("ISO8601DateFormatter is unavailable on this platform.")
}
self = .iso8601
case let (.formatted(encodingFormatter), .formatted(decodingFormatter)):
guard encodingFormatter == decodingFormatter else {
Expand All @@ -109,9 +106,6 @@ public enum DateCodingStrategy: RawRepresentable {
case .secondsSince1970:
return (.secondsSince1970, .secondsSince1970)
case .iso8601:
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
fatalError("ISO8601DateFormatter is unavailable on this platform.")
}
return (.iso8601, .iso8601)
case let .formatted(formatter):
return (.formatted(formatter), .formatted(formatter))
Expand Down
24 changes: 10 additions & 14 deletions Tests/BSONTests/DocumentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,9 @@ final class DocumentTests: MongoSwiftTestCase {
let millisecondsSince1970 = try encoder.encode(dateStruct)
expect(millisecondsSince1970["date"]).to(equal(.int64(date.msSinceEpoch)))

if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
encoder.dateEncodingStrategy = .iso8601
let iso = try encoder.encode(dateStruct)
expect(iso["date"]).to(equal(.string(BSONDecoder.iso8601Formatter.string(from: date))))
}
encoder.dateEncodingStrategy = .iso8601
let iso = try encoder.encode(dateStruct)
expect(iso["date"]).to(equal(.string(BSONDecoder.iso8601Formatter.string(from: date))))

let formatter = DateFormatter()
formatter.timeStyle = .full
Expand Down Expand Up @@ -819,15 +817,13 @@ final class DocumentTests: MongoSwiftTestCase {
expect(try decoder.decode(DateWrapper.self, from: badlyFormatted)).to(throwError(CodecTests.dataCorruptedErr))
expect(try decoder.decode(DateWrapper.self, from: sDouble)).to(throwError(CodecTests.typeMismatchErr))

if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
decoder.dateDecodingStrategy = .iso8601
let isoDoc: BSONDocument = ["date": .string(BSONDecoder.iso8601Formatter.string(from: date))]
let isoStruct = try decoder.decode(DateWrapper.self, from: isoDoc)
expect(isoStruct.date).to(equal(date))
expect(try decoder.decode(DateWrapper.self, from: formatted)).to(throwError(CodecTests.dataCorruptedErr))
expect(try decoder.decode(DateWrapper.self, from: badlyFormatted))
.to(throwError(CodecTests.dataCorruptedErr))
}
decoder.dateDecodingStrategy = .iso8601
let isoDoc: BSONDocument = ["date": .string(BSONDecoder.iso8601Formatter.string(from: date))]
let isoStruct = try decoder.decode(DateWrapper.self, from: isoDoc)
expect(isoStruct.date).to(equal(date))
expect(try decoder.decode(DateWrapper.self, from: formatted)).to(throwError(CodecTests.dataCorruptedErr))
expect(try decoder.decode(DateWrapper.self, from: badlyFormatted))
.to(throwError(CodecTests.dataCorruptedErr))

decoder.dateDecodingStrategy = .custom({ decode in try Date(from: decode) })
let customDoc: BSONDocument = ["date": .double(date.timeIntervalSinceReferenceDate)]
Expand Down