Shims (extension functions) to better match JDK's API
(If this is a duplicate issue, apologies. I didn't spot it.)
To aid in migration from JDK's datetime API to kotlinx-datetime, shims would be helpful. An example:
/** Shim for compatibility with JDK's `Instant` */
public fun Instant.minusSeconds(seconds: Long): Instant =
this - Duration.seconds(seconds)
This example gives the same API call for kotlinx-datetime Instant as for JDK's Instant class. I stumbled on this while migrating a project from JDK's API to kotlinx-datetime. These kind of shims are helpful to encourage migration, and make it more painless. An ideal situation would be just:
- Update the build dependencies
- Update the import statements in Kotlin source files
Were the shims in a separate dependency, that would be just as simple (only step # 1 changes) if that were better aligned with project goals.
@binkley Idk if you're still interested in this but check this library I made to address the missing extension functions in the original library here -> https://github.com/RaedGhazal/kotlinx-datetime-ext
** let me know if sharing links isn't allowed here