hello :wave::skin-tone-2: , I am running into an i...
# kotlinx-datetime
r
hello 👋🏻 , I am running into an issue with multiplatform. I am exposing
Duration
and the iOS project isn't able to see any of the kotlin datetime functions/classes. What's the recommended approach for working with this on the iOS side?
h
Duration is defined in the stdlib, unrelated to kotlinx-datetime. If you mean Instant, this could help you: https://github.com/Kotlin/kotlinx-datetime/issues/78#issuecomment-740573900
r
Oh, my mistake then. This is still helpful, thanks 👍🏻
m
Duration
is an inline value class and the Objective-C interop doesn't suppor them, and they all become just
Longs
. I found this hard to use from Swift since the
Long
doesn't represent something simple like total milliseconds, but instead encodes information about the duration in the most significant bit. I ended up creating a wrapper around duration for my public API.
r
Thanks for that insight @mkrussel. Do you mind sharing more about your duration wrapper?
m
Not much to say about it. It's just a normal class that exposes a lot of the same functionality as
Duration
and delegates to a
Duration
. For me, we created our class before we looked at Kotlin's
Duration
class. When we tried to switch to it, we found that using
Duration
from Swift was hard, so instead kept the original class design and changed the implementation.