Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dkhalanskyjb
Copy link
Contributor

@dkhalanskyjb dkhalanskyjb commented Aug 22, 2024

Issue: #395

```

```kotlin
// Darwin

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.

Copy link
Member

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

Copy link
Contributor

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

Copy link
Contributor

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.

Comment on lines +947 to +980
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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@dkhalanskyjb dkhalanskyjb marked this pull request as ready for review October 1, 2024 13:24
@dkhalanskyjb dkhalanskyjb mentioned this pull request Oct 1, 2024
* ### 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.
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@fvasco
Copy link

fvasco commented Oct 25, 2024

The Java Time API defined by JSR 310 is provided as part of JDK-8

https://jcp.org/aboutJava/communityprocess/pfd/jsr310/JSR-310-guide.html

dkhalanskyjb added a commit to Kotlin/kotlinx.serialization that referenced this pull request Mar 4, 2025
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
dkhalanskyjb added a commit to Kotlin/kotlinx.serialization that referenced this pull request Mar 4, 2025
kotlinx.datetime.Instant entered the stdlib as kotlin.time.Instant,
and so kotlinx.serialization takes over its serializers.
See Kotlin/KEEP#387
dkhalanskyjb added a commit to Kotlin/kotlinx.serialization that referenced this pull request Mar 4, 2025
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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copy link
Member

@ilya-g ilya-g Mar 11, 2025

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.

dkhalanskyjb and others added 2 commits March 6, 2025 12:35
dkhalanskyjb added a commit to JetBrains/kotlin that referenced this pull request Mar 6, 2025
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
@dkhalanskyjb dkhalanskyjb force-pushed the dkhalanskyjb-instant branch from bb89c13 to e636c1a Compare March 6, 2025 12:08
KotlinBuild pushed a commit to JetBrains/kotlin that referenced this pull request Mar 6, 2025
…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]>
@dkhalanskyjb dkhalanskyjb requested review from fzhinkin and ilya-g March 7, 2025 10:39
Copy link
Contributor

@fzhinkin fzhinkin left a 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

@dkhalanskyjb dkhalanskyjb requested a review from fzhinkin March 11, 2025 05:39
Copy link
Member

@ilya-g ilya-g left a 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.

@dkhalanskyjb dkhalanskyjb requested a review from ilya-g March 17, 2025 14:04
@dkhalanskyjb dkhalanskyjb merged commit 0d403e2 into Kotlin:master Mar 20, 2025
@dkhalanskyjb dkhalanskyjb deleted the dkhalanskyjb-instant branch March 20, 2025 15:10
dkhalanskyjb added a commit to Kotlin/kotlinx.serialization that referenced this pull request Apr 2, 2025
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
dkhalanskyjb added a commit to Kotlin/kotlinx.serialization that referenced this pull request Apr 15, 2025
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
dkhalanskyjb added a commit to Kotlin/kotlinx.serialization that referenced this pull request Jun 25, 2025
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
sandwwraith pushed a commit to Kotlin/kotlinx.serialization that referenced this pull request Jun 25, 2025
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
JesusMcCloud pushed a commit to JesusMcCloud/kotlinx.serialization that referenced this pull request Aug 5, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants