Date/time best practices for Kotlin Native


Is there a best practice we can apply for retrieving the current system date and time in Kotlin Native?
We are unable to import java.util.Date and are not really sure if this is even the correctly path to take.
What is the os.time() equivalent for Kotlin Native?


I believe the plan is to extend the standard library with classes for Date/Time (and many other things) so that applications written with the JVM, JS and Native versions of Kotlin can share the same code.

The underlying basis for each version will of course be different and, for Native, I’d imagine they’ll probably use the structs and functions defined in time.h of the C standard library.

These should be available ‘out of the box’ if you import Platform.Posix so I’d suggest you use them either in their ‘raw’ form or by writing a simple wrapper until such time as the Kotlin standard library is extended to include Date/Time support.


Thanks Alan, your answer was really helpful. We did as you said and went down the time.h C standard library for now.