Which date library can be used in compose-web proj...
# compose-web
g
Which date library can be used in compose-web projects? I'm using Jetbrains Exposed on my server, which supports Java8 date, Jodatime and Kotlinx, but none of them, it seems, are supported i wasm/js...
h
kotlinx-datetime supports wasmJS since 0.5.0. And how is wasmJS related to your server DB framework?
g
I'm storing entries with dates in a database, the wasm frontent app might create new entries for the database, while it can receive them without a problem, constructing one fails, because Kotlinx dates can't be found in wasm project...
h
You need to send the dates over the wire, eg with kotlinx serialization so the server db framework is unrelated. And what datetime version do you use?
g
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1")
I have this dependency in shared tree
yet I can't construct instance of a class that contains
LocalDateTime
in wasmJS
m
With the above dependency declaration in commonMain I can do this without problem in common code and run it in a browser.
Copy code
val dateTime: LocalDateTime = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
g
With such dependencies in commonMain:
Copy code
sourceSets {
        commonMain.dependencies {
            // put your Multiplatform dependencies here
            implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.2")
            implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1")
        }
        jvmMain {
            dependencies {
            }
        }
    }
LocalDateTime, Clock and TimeZone are not available in composeApp for me.
m
I’d first go back to serialization 1.7.1 because there is currently a problem with 1.7.2. See: https://github.com/Kotlin/kotlinx.serialization/issues/2810#issuecomment-2338008697 I don’t know whether that’s related to your problem but at least it’s worth a try.