kotlinx-datetime
kotlinx-datetime copied to clipboard
Choose the standard timezone database provider for JS and Wasm
There's a pure Kotlin implementation of the datetime library for Kotlin/Native. This code can be used directly to implement the JS and Wasm targets—except for timezone database access.
- There's a discussion about exposing the timezone database via WASI: https://github.com/WebAssembly/WASI/issues/25
- We could keep using js-joda's (https://github.com/js-joda/js-joda) timezone database, even if we reimplement the code for database calculations.
- Maybe other libraries provide timezone database access? There is https://www.npmjs.com/package/@vvo/tzdb, but it doesn't seem to have historical data.
- There is timezone support in JS's
Intlfor formatting (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat); maybe the underlying data is available somehow. - We could ship our own timezone databases.
Related: https://github.com/Kotlin/kotlinx-datetime/issues/178 Previous discussion: https://github.com/Kotlin/kotlinx-datetime/issues/245
It might be valuable to add to the list an option to use c/c++ timezone databases for wasm target. E.g. the one which is used for Kotlin/Native.
@vdshb, please explain what you mean. In Kotlin/Native for Darwin and Linux, we used to use a C++ library that queried /usr/share/zoneinfo for us; now, even this code is in pure Kotlin. As I understand it, Wasm doesn't have access to /usr/share/zoneinfo.
@dkhalanskyjb My bad, I thought it works another way. It looks like WASI team implementing their own API to get timezone data https://github.com/WebAssembly/wasi-clocks/pull/61