I am not sure what to do for KotlinJS, and how it ...
# javascript
s
I am not sure what to do for KotlinJS, and how it relates to those 2 functions.
s
For js in the browser there are
Date.getTime()
and https://developer.mozilla.org/en-US/docs/Web/API/Performance
Not sure if you need more than that
s
Alright, that also point to that there is no alternative for
getTimeNanos
or
CLOCK_MONOTONIC
in Js.
s
Well, javas is pretty much best effort also:
Copy code
This method provides nanosecond precision, but not necessarily
     * nanosecond resolution (that is, how frequently the value changes)
     * - no guarantees are made except that the resolution is at least as
     * good as that of {@link #currentTimeMillis()}.
s
Yes, I am aware of that. It depends a lot on the underlying system, which is fine.
I am working on a
Clock
abstraction for Arrow. Some other MPP languages (or frameworks in languages) I checked offer both since
nanos
is better suited for tracking timed events compared to
millis
.
I was wondering if Kotlin had already thought out something for this issue.
r
Jetbrains is working on a mpp date-time thing iirc
👍 3
s
Ah awesome thanks! Any references would be appreciate, can’t seem to find anything
r
Last time I heard about it it was more of a plan I think, I’m not sure. There were also talks about a mpp file lib
f
You can use this library for mpp projects: https://github.com/korlibs/klock
r
That works but I don’t like its API
s
Thanks for the reference @fcosta. I'll check the sources of that repo :)
b
in Kotlin/JS you can write something like
js("Date").now()
or
window.performance.now()
for
window
you need
import kotlin.browser.window
s
@bashor awesome! thanks for the response