-
Notifications
You must be signed in to change notification settings - Fork 373
Describe moving kotlinx.datetime.Instant to stdlib #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe moving kotlinx.datetime.Instant to stdlib #387
Conversation
``` | ||
|
||
```kotlin | ||
// Darwin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the UUID KEEP, the stdlib is not specialized for various native targets today. These extensions would no longer be possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move them to the "Future enhancements" section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to update KDoc in the corresponding implementation. @dkhalanskyjb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to update KDoc in the corresponding implementation.
Never mind, it looks OK as of now.
It is not obvious to people who want to obtain the current `Instant` that a | ||
class like `Clock` even exists, so we direct them to it using a deprecation with | ||
a proposed replacement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't documentation for the Instant
class enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anyone does read it, it should be enough. Instant.now()
is for establishing a smooth enough migration using the compiler errors that it's straightforward to arrive at correct code without reading anything, just with autocomplete.
3852f17
to
7eabfbe
Compare
proposals/stdlib/instant.md
Outdated
* ### Platform specifics | ||
* | ||
* On the JVM, there are `Instant.toJavaInstant()` and `java.time.Instant.toKotlinInstant()` | ||
* extension functions to convert between `kotlinx.datetime` and `java.time` objects used for the same purpose. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package is no longer kotlinx.datetime
.
leap seconds. | ||
|
||
<https://github.com/ThreeTen/threeten-extra/tree/4e016340b97cab604114d10e02a672c1e94c6be5/src/main/java/org/threeten/extra/scale> | ||
is an implementation that converts between "UTC `Instant`", a new class, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is an implementation that converts between "UTC `Instant`", a new class, and | |
is an implementation that converts between "`UtcInstant`", a new class, and |
assuming you wanted to mention the actual class name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkhalanskyjb should we use the actual class name here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the name of the class is important here. If it were called LeapSecondAwareInstant
or something similar, I'd still prefer calling it a "UTC Instant
", that is, an Instant
using the UTC time-scale.
https://jcp.org/aboutJava/communityprocess/pfd/jsr310/JSR-310-guide.html |
Can be merged after moving to Kotlin 2.1.20, which introduces kotlin.time.Instant. Previously, when kotlinx.datetime.Instant serializers were available in kotlinx-datetime. See Kotlin/KEEP#387
kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. See Kotlin/KEEP#387
Can be merged after moving to Kotlin 2.1.20, which introduces kotlin.time.Instant. kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. See Kotlin/KEEP#387
nondeterministic and difficult to reliably test, whereas passing a `Clock` | ||
to it makes calling `now()` a functionally pure operation. | ||
|
||
### Migration process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave a description of that process we've chosen to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant leave only that description because having others at this point doesn't bring much use and can lead to confusion for those reading this and trying to figure out what to expect from this change migration-wise.
Co-authored-by: ilya-g <[email protected]>
Co-authored-by: Abduqodiri Qurbonzoda <[email protected]>
After moving `Instant` from `kotlinx.datetime` to `kotlin.time`, we also need to preserve it having a default `kotlinx.serialization` serializer. See Kotlin/KEEP#387 The corresponding request in `kotlinx.serialization`: Kotlin/kotlinx.serialization#2945
bb89c13
to
e636c1a
Compare
…rializers After moving `Instant` from `kotlinx.datetime` to `kotlin.time`, we also need to preserve it having a default `kotlinx.serialization` serializer. See Kotlin/KEEP#387 The corresponding request in `kotlinx.serialization`: Kotlin/kotlinx.serialization#2945 Additionally, fix a test that was not being run correctly. Merge-request: KT-MR-20493 Merged-by: Dmitry Khalanskiy <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkhalanskyjb could you please address remaining open questions (about interop with Foundation libraries, mainly)?
Otherwise, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to leave only the actual chosen migration process description.
Can be merged after moving to Kotlin 2.1.20, which introduces kotlin.time.Instant. kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. See Kotlin/KEEP#387
Can be merged after moving to Kotlin 2.1.20, which introduces kotlin.time.Instant. kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. See Kotlin/KEEP#387
Can be merged after moving to Kotlin 2.1.20, which introduces kotlin.time.Instant. kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. See Kotlin/KEEP#387
Add kotlin.time.Instant serializers kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. (toString() one and ComponentSerializer). See Kotlin/KEEP#387 * Move the tests for the Instant serializers Original version: https://github.com/Kotlin/kotlinx-datetime/blob/72681c2acaf9addf5effdef8ecd0975f6f7d10a7/serialization/common/test/InstantSerializationTest.kt * Improve the documentation
Add kotlin.time.Instant serializers kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant, and so kotlinx.serialization takes over its serializers. (toString() one and ComponentSerializer). See Kotlin/KEEP#387 * Move the tests for the Instant serializers Original version: https://github.com/Kotlin/kotlinx-datetime/blob/72681c2acaf9addf5effdef8ecd0975f6f7d10a7/serialization/common/test/InstantSerializationTest.kt * Improve the documentation
Issue: #395