diff --git a/CHANGELOG.md b/CHANGELOG.md index 412adbb..b2f1992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 0.1.1 + +Released 2024-05-25 + + - Add Timestamp properties and functions + - Fix Timestamp Hashable + - Re-enable tests + - Add Timestamp + - Bump firebase-bom version to 33.0.0; add more docs to README + - ci: update workflow actions location + - Update docs to mention sample Fireside app + ## 0.1.0 Released 2024-02-05 diff --git a/Sources/SkipFirebaseFirestore/SkipFirebaseFirestore.swift b/Sources/SkipFirebaseFirestore/SkipFirebaseFirestore.swift index 5f37956..6a6b179 100644 --- a/Sources/SkipFirebaseFirestore/SkipFirebaseFirestore.swift +++ b/Sources/SkipFirebaseFirestore/SkipFirebaseFirestore.swift @@ -792,10 +792,14 @@ public class Timestamp: Hashable, KotlinConverting Date { + public func dateValue() -> Date { Date(platformValue: timestamp.toDate()) } + public func toDate() -> Date { + dateValue() + } + public var seconds: Int64 { timestamp.seconds } diff --git a/Tests/SkipFirebaseFirestoreTests/SkipFirebaseFirestoreTests.swift b/Tests/SkipFirebaseFirestoreTests/SkipFirebaseFirestoreTests.swift index 8c857d8..55255b2 100644 --- a/Tests/SkipFirebaseFirestoreTests/SkipFirebaseFirestoreTests.swift +++ b/Tests/SkipFirebaseFirestoreTests/SkipFirebaseFirestoreTests.swift @@ -190,7 +190,10 @@ final class SkipFirebaseFirestoreTests: XCTestCase { } } - XCTAssertEqual(Timestamp(date: Date(timeIntervalSince1970: 12345)), Timestamp(seconds: 12345, nanoseconds: 0)) + let ts = Timestamp(seconds: 12345, nanoseconds: 100_000_000) + XCTAssertEqual(12345, ts.seconds) + XCTAssertEqual(100_000_000, ts.nanoseconds) + XCTAssertEqual(12345.1, ts.dateValue().timeIntervalSince1970, accuracy: 0.001) let bos = citiesRef.document("BOS") @@ -259,11 +262,11 @@ final class SkipFirebaseFirestoreTests: XCTestCase { } // follow-on test since running multiple separate firestore tests in a single case seems to fail (possibly due to re-configuration of the FirebaseApp app) - try await XXXtestFirestoreQuery() - //try await XXXtestFirestoreBundles() + try await followon_testFirestoreQuery() + //try await followon_testFirestoreBundles() } - func XXXtestFirestoreQuery() async throws { + func followon_testFirestoreQuery() async throws { XCTAssertEqual(appName, self.app.name) let db = Firestore.firestore(app: self.app) @@ -301,7 +304,7 @@ final class SkipFirebaseFirestoreTests: XCTestCase { //try await XXXtestFirestoreBundles() } - func XXXtestFirestoreBundles() async throws { + func followon_testFirestoreBundles() async throws { // see Resources/ firestore_bundle-1.json, firestore_bundle-2.json, firestore_bundle-3.json let bundle1 = try Data(contentsOf: XCTUnwrap(Bundle.module.url(forResource: "firestore_bundle-1", withExtension: "json")))