Kotlin / kotlinx-datetime

KotlinX multiplatform date/time library
Apache License 2.0
2.42k stars 101 forks source link

Locale for JS not working? #456

Closed alekseyHunter closed 1 day ago

alekseyHunter commented 1 day ago

Hello!

I'm trying to format LocalDateTime with next pattern "dd MMMM":

actual fun LocalDateTime.format(format: String): String {
    return DateTimeFormatter.ofPattern(format)
        .withLocale("ru" as Locale)
        .format(
            nativeJs(
                Date(
                    milliseconds = this.toInstant(
                        TimeZone.currentSystemDefault()
                    ).toEpochMilliseconds()
                )
            )
        )
}

I got the next error: image

dkhalanskyjb commented 1 day ago

Hi! DateTimeFormatter, withLocale, Locale, nativeJs, and Date are not parts of this library at all, so we can't help you with that.

Our own implementation of formatting also currently doesn't support locales: https://github.com/Kotlin/kotlinx-datetime/issues/352