Does anyone know how to instantiate a Javascript Date using Kotlin?


#1

As this class: https://github.com/JetBrains/kotlin/blob/master/js/js.libraries/src/core/date.kt has no constructor arguments...

Thanks,

Jørund


#2

Hi, Jørund

Please file issue to the tracker.

As workaround You can write own native declaration with missed constructors and feel free to contibute :).


#3

Additionally, You can use "magic" function js and write something like:

val d: Date = js("new Date(2015, 11, 11)") println(d)


#4

  

@native(“new Date”)
public fun jsDate(time:Long): Date = kotlin.js.Date();