`kotlinx.datetime.Instant` would be visible to iOS...
# kotlinx-datetime
c
kotlinx.datetime.Instant
would be visible to iOS as
Kotlinx_datetimeInstant
Since it is moved to the stdlib, what should it be exported as?
Kotlin_timeInstant
is not found, neither is just Instant.
d
I don't know the actual answer, but here are some pointers. The general approach of making Kotlin APIs available from native code: https://github.com/Kotlin/kotlinx-datetime/issues/78 Converter functions that allow you to avoid exposing
Instant
to Native and instead use a native
NSDate
object: • https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/to-n-s-date.htmlhttps://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/to-kotlin-instant.html
c
I have this in my app
Copy code
extension Date {
    static func instantFromEpochSeconds(date: Date) -> Kotlinx_datetimeInstant {
        return Kotlinx_datetimeInstant.Companion()
            .fromEpochSeconds(
                epochSeconds: Int64(date.timeIntervalSince1970),
                nanosecondAdjustment: Int32(0)
            )
    }
}
I just want to change the return type of this Swift function.
Okay I found out that the I need to use
KotlinInstant
in place of
Kotlinx_datetimeInstant
However like Dmitry mentioned above, this is probably not the best approach. I should change my APIs such that Instant should never have to be used directly from Swift.