Skip to content

Commit

Permalink
[RKOTLIN-1137] Fix incorrect currentTime() for Android devices on API…
Browse files Browse the repository at this point in the history
… 25 and below (#1850)
  • Loading branch information
stavfx authored Jan 20, 2025
1 parent df49eef commit 9cdc455
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* None.

### Fixed
* None.
* `RealmInstant.now` was returning incorrect value on Android devices running API 25 and below (Issue: [#1849](https://github.com/realm/realm-kotlin/issues/1849)).

### Compatibility
* File format: Generates Realms with file format v24 (reads and upgrades file format v10 or later).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public actual fun currentTime(): RealmInstant {
val jtInstant = java.time.Clock.systemUTC().instant()
RealmInstantImpl(jtInstant.epochSecond, jtInstant.nano)
} else {
RealmInstantImpl(System.currentTimeMillis(), 0)
val now = System.currentTimeMillis()
RealmInstantImpl(now / 1000, (now % 1000).toInt() * 1_000_000)
}
}

0 comments on commit 9cdc455

Please sign in to comment.