Nikky
10/27/2020, 10:26 AMClock.System.now().toEpochMilliseconds()
is the equivalent of System.getCurrentMillis()
?ilya.gorbunov
10/27/2020, 5:00 PMlouiscad
10/27/2020, 5:30 PMMarc Knaup
10/28/2020, 6:20 PMLong
.
Clocks should provide epoch millis without intermediate Instant
.louiscad
10/28/2020, 6:34 PMInstant
an inline class? If not, maybe it'll be once they are stabilized?Marc Knaup
10/28/2020, 6:35 PMlouiscad
10/28/2020, 6:39 PMilya.gorbunov
10/29/2020, 10:30 AMMarc Knaup
10/29/2020, 10:34 AMInstant
becomes noticeable (fortunately that’s rare for me)Marc Knaup
10/29/2020, 10:37 AMDate
, Instant
(Java), Timestamp
(own time lib), GMTDate
(ktor) and Instant
(kotlinx-datetime).
Converting between all those is based on epoch millis and often intermediate instances of either of them are created. That’s annoying when I want to optimize for high performance low memory when that’s done tens of thousands of times.
Usually the current time in millis is used to compare one of those dates with the current system time, e.g. to check if a specific date has passed.Marc Knaup
10/29/2020, 10:39 AMclock.durationSince(timestamp)
and clock.durationUntil(timestamp)
. Then I can check without allocation if a certain date (with leeway) has passed.louiscad
10/29/2020, 10:40 AMInstant
, kotlin.time
can suit several use cases. Take this snippet for example: TimeSource.Monotonic.markNow().hasPassedNow()
Marc Knaup
10/29/2020, 10:40 AMMarc Knaup
10/29/2020, 10:41 AMlouiscad
10/29/2020, 10:41 AMTimeMark
I thinklouiscad
10/29/2020, 10:41 AMTimeSource
Marc Knaup
10/29/2020, 10:42 AMMarc Knaup
10/29/2020, 10:42 AMMarc Knaup
10/29/2020, 10:50 AM@Marc Knaup You don’t always needAlso, that doesn’t account for leeway. What if I want to check “I’m 5 seconds after `Instant`“?,Instant
can suit several use cases. Take this snippet for example:kotlin.time
TimeSource.Monotonic.markNow().hasPassedNow()
louiscad
10/29/2020, 10:51 AMInstant
to a TimeMark
beforehand.louiscad
10/29/2020, 10:51 AMMarc Knaup
10/29/2020, 10:52 AMMarc Knaup
10/29/2020, 10:53 AMlouiscad
10/29/2020, 10:58 AMInstant
to TimeMark
?Marc Knaup
10/29/2020, 12:31 PMInstant
are coming from.
And even then - it’s just way too complicated for something as simple as comparing time against the clock efficiently.