Skip to content

Remove kotlinx.datetime.Instant while preserving binary compatibility #506

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

Merged
merged 3 commits into from
Jun 20, 2025

Conversation

dkhalanskyjb
Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb commented Mar 31, 2025

Original implementation: #465.

@dkhalanskyjb dkhalanskyjb requested review from ilya-g and Copilot March 31, 2025 09:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the README documentation to reflect the removal of kotlinx.datetime.Instant in favor of kotlin.time.Instant while maintaining binary compatibility.

  • Updated documentation examples to use kotlin.time.Instant and kotlin.time.Clock.
  • Revised migration instructions and compatibility notes regarding the deprecation of kotlinx.datetime.Instant and kotlinx.datetime.Clock.
  • Adjusted library version compatibility and clarified usage notes for different platforms.
Files not reviewed (19)
  • core/api/kotlinx-datetime.api: Language not supported
  • core/api/kotlinx-datetime.klib.api: Language not supported
  • core/build.gradle.kts: Language not supported
  • core/common/src/Clock.kt: Language not supported
  • core/common/src/DeprecatedClock.kt: Language not supported
  • core/common/src/TimeZone.kt: Language not supported
  • core/common/src/format/DateTimeComponents.kt: Language not supported
  • core/common/src/serializers/DeprecatedInstantSerializers.kt: Language not supported
  • core/common/test/ClockTimeSourceTest.kt: Language not supported
  • core/common/test/DeprecatedClockTimeSourceTest.kt: Language not supported
  • core/common/test/InstantTest.kt: Language not supported
  • core/common/test/LocalDateTest.kt: Language not supported
  • core/common/test/LocalDateTimeTest.kt: Language not supported
  • core/common/test/ReadmeTest.kt: Language not supported
  • core/common/test/TimeZoneTest.kt: Language not supported
  • core/common/test/format/DateTimeComponentsFormatTest.kt: Language not supported
  • core/common/test/format/DateTimeComponentsTest.kt: Language not supported
  • core/common/test/samples/ClockSamples.kt: Language not supported
  • core/common/test/samples/DayOfWeekSamples.kt: Language not supported

@dkhalanskyjb dkhalanskyjb changed the base branch from master to kotlin-2.1.20 March 31, 2025 09:34
@dkhalanskyjb dkhalanskyjb added this to the 0.7.0 milestone Mar 31, 2025
@@ -12,9 +12,14 @@ public final class kotlinx/datetime/Clock$System : kotlinx/datetime/Clock {
}

public final class kotlinx/datetime/ClockKt {
public static final fun asClock (Lkotlin/time/TimeSource;Lkotlinx/datetime/Instant;)Lkotlinx/datetime/Clock;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be missing in DeprecatedClock.kt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is, but this is okay, since we never published a release with 73aad58

Copy link

Choose a reason for hiding this comment

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

image
Are you sure?

Copy link
Collaborator Author

@dkhalanskyjb dkhalanskyjb Apr 2, 2025

Choose a reason for hiding this comment

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

Not any longer! Sorry for missing the obvious, and thanks for picking up my slack.

Comment on lines 54 to 55
assertFailsWith<DateTimeArithmeticException> { (Instant.fromEpochSeconds(Long.MAX_VALUE) - 3.days).toLocalDateTime(TimeZone.UTC) }
assertFailsWith<DateTimeArithmeticException> { (Instant.fromEpochSeconds(Long.MIN_VALUE) + 6.hours).toLocalDateTime(TimeZone.UTC) }
Copy link
Member

Choose a reason for hiding this comment

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

Are such changes required if you already defined Instant.MIN/MAX extension properties for tests?

@dkhalanskyjb dkhalanskyjb force-pushed the remove-instant-compat branch 2 times, most recently from ca49943 to 5581303 Compare April 28, 2025 11:12
@dkhalanskyjb dkhalanskyjb changed the base branch from kotlin-2.1.20 to master April 28, 2025 11:43
@dkhalanskyjb dkhalanskyjb force-pushed the remove-instant-compat branch from 5581303 to 9a5a5e0 Compare June 11, 2025 09:31
dkhalanskyjb and others added 3 commits June 20, 2025 11:51
The DateTimeFormat-based FormattedInstantSerializer would be
introduced in this release for `kotlinx.datetime.Instant` if that
wasn't going to be removed.
Now, instead, we support the new, `kotlin.time.Instant` in this
serializer.
@dkhalanskyjb dkhalanskyjb force-pushed the remove-instant-compat branch from 9a5a5e0 to 9bebcf4 Compare June 20, 2025 09:57
@dkhalanskyjb dkhalanskyjb merged commit 1a1e102 into master Jun 20, 2025
1 check passed
@dkhalanskyjb dkhalanskyjb deleted the remove-instant-compat branch June 20, 2025 10:46
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.

4 participants