diff --git a/CHANGELOG.md b/CHANGELOG.md index d0fdbcf8e38..dc137e97743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ ----------- ### Internals -* None. +* Timestamp objects can now only be created from a system clock timepoint. ([#6112](https://github.com/realm/realm-core/issues/6112)) ---------------------------------------------- diff --git a/src/realm/timestamp.hpp b/src/realm/timestamp.hpp index 0e4d8bf288c..c1fd17f1fbe 100644 --- a/src/realm/timestamp.hpp +++ b/src/realm/timestamp.hpp @@ -80,8 +80,7 @@ class Timestamp { constexpr Timestamp(const Timestamp&) = default; constexpr Timestamp& operator=(const Timestamp&) = default; - template - constexpr Timestamp(std::chrono::time_point tp) + constexpr Timestamp(std::chrono::time_point tp) : m_is_null(false) { int64_t native_nano = std::chrono::duration_cast(tp.time_since_epoch()).count(); diff --git a/test/test_object_id.cpp b/test/test_object_id.cpp index dd9d3b39e96..1b35cf84223 100644 --- a/test/test_object_id.cpp +++ b/test/test_object_id.cpp @@ -264,7 +264,7 @@ TEST(ObjectId_PrimaryKey) { SHARED_GROUP_TEST_PATH(path); DBRef db = DB::create(path); - Timestamp now{std::chrono::steady_clock::now()}; + Timestamp now{std::chrono::system_clock::now()}; ObjectId id{now, 0, 0}; ObjKey key; { @@ -314,7 +314,7 @@ TEST_TYPES(ObjectId_Query, WithIndex, WithoutIndex) { SHARED_GROUP_TEST_PATH(path); DBRef db = DB::create(path); - auto now = std::chrono::steady_clock::now(); + auto now = std::chrono::system_clock::now(); ObjectId t0; ObjectId t25; ObjectId alternative_id("000004560000000000170232");