File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44* Update ObjectBox database for Flutter Android apps to ` 5.3.1-2026-03-26 ` .
55* Update ObjectBox database for Flutter iOS/macOS apps to ` 5.3.1-2026-03-26 ` .
66
7+ ### Sync
8+
9+ * Add ` Sync.syncClockTimestamp() ` to get an timestamp from a Sync clock (and a variation for a corrected timestamp)
10+
711## 5.3.0 (2026-03-25)
812
13+ ** Warning:** Do not use this version for sync clocks, it contains a sever bug! Use 5.3.1 instead.
14+
915* Update ObjectBox database for Flutter Linux/Windows, Dart Native apps to [ 5.3.0-2026-03-23] ( https://github.com/objectbox/objectbox-c/releases/tag/v5.3.0 )
1016* Update ObjectBox database for Flutter Android apps to ` 5.3.0-2026-03-23 ` .
1117 If your project is [ using Admin] ( https://docs.objectbox.io/data-browser#admin-for-android ) , make
Original file line number Diff line number Diff line change @@ -893,6 +893,24 @@ class Sync {
893893 /// Returns true if the loaded ObjectBox native library supports Sync.
894894 static bool isAvailable () => _syncAvailable;
895895
896+ /// Gets the "raw" timestamp (milliseconds since epoch) from the given sync
897+ /// clock value.
898+ ///
899+ /// Note that sync clock values are assigned by ObjectBox and are not to be
900+ /// interpreted on their own. Use this function to extract a meaningful
901+ /// timestamp from a sync clock value (e.g. stored in a [@SyncClock] field).
902+ static int syncClockTimestamp (int syncClockValue) =>
903+ C .sync_clock_timestamp (syncClockValue);
904+
905+ /// Gets the corrected timestamp (milliseconds since epoch) from the given
906+ /// sync clock value.
907+ ///
908+ /// Like [syncClockTimestamp] , but applies any time correction if present in the
909+ /// sync clock value. However, for most cases, it will return the same value
910+ /// as [syncClockTimestamp] .
911+ static int syncClockTimestampCorrected (int syncClockValue) =>
912+ C .sync_clock_timestamp_corrected (syncClockValue);
913+
896914 /// Creates a [SyncClient] associated with the given store and configures it
897915 /// with the given options. This does not initiate any connection attempts
898916 /// yet, call [SyncClient.start] to do so.
Original file line number Diff line number Diff line change @@ -336,6 +336,15 @@ void main() {
336336 client.close ();
337337 });
338338
339+ test ('syncClockTimestamp' , () {
340+ final clockValue = 1860802100721610852 ;
341+ final expectedTime = 1774599171372 ;
342+
343+ expect (Sync .syncClockTimestamp (clockValue), equals (expectedTime));
344+ expect (Sync .syncClockTimestampCorrected (clockValue),
345+ equals (expectedTime - 10 ));
346+ });
347+
339348 group ('Server tests using sync-server in PATH' , () {
340349 late SyncServer server;
341350
@@ -562,8 +571,7 @@ void main() {
562571 final id = box.put (object);
563572
564573 final read = box.get (id)! ;
565- // Upper 44 bits are ms since epoch
566- final clockMs = read.clock! >> 20 ;
574+ final clockMs = Sync .syncClockTimestamp (read.clock! );
567575 final nowMs = DateTime .now ().millisecondsSinceEpoch;
568576 expect ((clockMs - nowMs).abs (),
569577 lessThanOrEqualTo (Duration .millisecondsPerMinute),
You can’t perform that action at this time.
0 commit comments