What does the `Long` represent? Miliseconds since ...
# javascript
k
What does the
Long
represent? Miliseconds since epoch?
h
Yes
s
In kotlin/js Long represented as double
you can (long).unsafeCast() it and pass to Date constructor
k
Long isn't represented as double, from the docs:
There's no 64 bit integer number in JavaScript, so kotlin.Long is not mapped to any JavaScript object, it's emulated by a Kotlin class.
s
hmm. I'm missed this. Thank for link
h
Yes taking help of inter operability
That's seems a solution
Will share a code after success
s
Looks like this works:
Copy code
@JsName("Date")
external class JsDate {
    constructor (value: Double)
}

fun main(args: Array<String>) {
    val unixTs = 1509703486L * 1000L
    println(JsDate(unixTs.toDouble()))
}
This compiles to:
Copy code
var unixTs = new Kotlin.Long(-2125002192, 351);
    println(new Date((new Kotlin.Long(-2125002192, 351)).toNumber()));
And prints "Fri Nov 03 2017 130446 GMT+0300 (MSK) " for me