Kotlin / kotlinx-datetime

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

Support Native Tier 3 targets #311

Closed sandwwraith closed 8 months ago

sandwwraith commented 1 year ago

As said in the official recommendations, library authors are encouraged to provide builds for tier 3 targets. Currently, they're commented out:

// the following targets are not supported by kotlinx.serialization:
        /*
        target("androidNativeArm32")
        target("androidNativeArm64")
        target("androidNativeX86")
        target("androidNativeX64")
         */

But kotlinx.serialization actually supports them starting from 1.5.1

dkhalanskyjb commented 1 year ago

You are right, sorry for the libel! Yes, the comment is outdated; the true reason these targets are not provided is that we haven't implemented the timezone database access for them.

natario1 commented 8 months ago

On Android the zoneinfo database seems to be available at /system/usr/share/zoneinfo, at least on the devices in my possession. I don't have any link documenting this, but I doubt one exists.

The rest of the code could be identical to the linux implementation as far as I can see.

dkhalanskyjb commented 8 months ago

The rest of the code could be identical to the linux implementation as far as I can see.

Not really; these are files and not directories, and we would need to research how they are parsed. We can look into this if there's demand, but I don't think I've seen anyone asking for this yet.

natario1 commented 8 months ago

It's more of an ecosystem blocker, because you are at the root of the graph. This is blocking square/okio, which is also a common dependency at the root of many square projects and thus everybody's projects.

At the leaves of this dependency tree there likely are many people, users and lib maintainers, asking or wondering about androidNative support. I, for example, stumbled upon this after opening square/okio#1326 which I had openend because it is blocking some other kotlinx library (can't remember which one now).

So I think this should be done even if it's there's not much direct request. I'm happy to help too, even though I don't care about timezone's and maybe nor does okio. If system/usr/shareinfo is there, I would hope there's some AOSP code that parses it that you could look at.

dkhalanskyjb commented 8 months ago

I, for example, stumbled upon this after opening https://github.com/square/okio/issues/1326

Thanks for sharing this: without this link, I didn't know at all that we were blocking anyone at all.

I don't care about timezone's and maybe nor does okio.

Yep, git grep in their code only shows Clock and Instant. Not sure how much utility our library brings to them.

natario1 commented 8 months ago

This code parses the database file, looking for a specific ID (you might know what that is, I don't): https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/tzcode/bionic.cpp;l=131?q=libc%2Ftzcode%2Fbionic.cpp .

There are also other libs that parse the file in a simpler way: https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/grpcio-sys/grpc/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc;l=696-728?q=system%2Fusr%2Fshare%2Fzoneinfo

The latter looks pretty straightforward.