Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dkhalanskyjb
Copy link

No description provided.

proposals/stdlib/instant.md Outdated Show resolved Hide resolved
```

```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.

proposals/stdlib/instant.md Outdated Show resolved Hide resolved
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?

proposals/stdlib/instant.md Outdated Show resolved Hide resolved
proposals/stdlib/instant.md Outdated Show resolved Hide resolved
proposals/stdlib/instant.md Outdated Show resolved Hide resolved
@dkhalanskyjb dkhalanskyjb marked this pull request as ready for review October 1, 2024 13:24

### `Instant`

`Instant` denotes a moment in time, regardless of the observer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe best to remove the phrase "regardless of observer" since that evokes relativistic effects. According to the theory of relativity, simultaneity is relative. If events occur in different places, there may be frames of reference in which they are simultaneous, other frames in which one occurs first and other frames in which the other occurred first.

There is no "absolute" frame of reference from which we can say that two events occurring at different places occurred at the "same instant".

So, I'm thinking it's probably best not to mention "observers" since none of our usual language and intuition about instants or clocks works when we try to account for observers in different reference frames.

Copy link
Author

Choose a reason for hiding this comment

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

Doesn't "regardless of the observer" strongly imply that relativistic effects are not accounted for, given that this definition is absurd in the context of relativity?

Copy link
Contributor

Choose a reason for hiding this comment

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

"Regardless of observer" means "for any observer." Or "in any frame of reference."

But everything else we're talking about here is only true if everyone is in the same frame of reference.

In other words, only for specific observers.

So using the phrase "regardless of observer" is the opposite of what we want.

Probably best just not to mention observers.

* ### 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

Comment on lines +808 to +824
// Constructing
println(runCatching {
java.time.Instant.ofEpochSecond(Long.MAX_VALUE)
}) // Failure(java.time.DateTimeException: Instant exceeds minimum or maximum instant)
println(runCatching {
kotlinx.datetime.Instant.fromEpochSeconds(Long.MAX_VALUE)
}) // Success(+1000000000-12-31T23:59:59.999999999Z)

// Arithmetics
println(runCatching {
java.time.Instant.EPOCH
.plusSeconds(Long.MAX_VALUE)
}) // Failure(java.time.DateTimeException: Instant exceeds minimum or maximum instant)
println(runCatching {
kotlinx.datetime.Instant.fromEpochMilliseconds(0)
.plus(kotlin.time.Duration.INFINITE)
}) // Success(+1000000000-12-31T23:59:59.999999999Z)
Copy link
Contributor

Choose a reason for hiding this comment

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

is the kotlinx.datetime package intended here?

<https://www.rfc-editor.org/rfc/rfc3339#section-5.6>.
Both of these formats are widely used, but also human-readable.

Example: `2024-08024T16:22:34Z`.
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
Example: `2024-08024T16:22:34Z`.
Example: `2024-08-24T16:22:34Z`.

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.

5 participants