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

String.toInstant throws exception on macosx64, but not jvm #269

Closed
05nelsonm opened this issue Apr 27, 2023 · 2 comments
Closed

String.toInstant throws exception on macosx64, but not jvm #269

05nelsonm opened this issue Apr 27, 2023 · 2 comments

Comments

@05nelsonm
Copy link

Got a DateTimeFormatException when converting a string value which was produced on jvm. to an Instant on macosx64

// jvm

val instantString = Clock.System.now().plus(Int.MAX_VALUE.days).toString()
instantString.toInstant() // << does not throw

println(instantString)
// +5881633-11-04T10:51:10.025414219Z
// macosx64
"+5881633-11-04T10:51:10.025414219Z".toInstant() // << throws DateTimeFormatException
@dkhalanskyjb
Copy link
Collaborator

Native and JS support a much smaller range of years than JVM, namely years ±1000000 at most, instead of ±1000000000 for the JVM. We didn't consider dates outside the smaller range to be useful in practice.

The only values that are guaranteed to work across all platforms are those between Instant.DISTANT_PAST and Instant.DISTANT_FUTURE.

@05nelsonm
Copy link
Author

Yes, that is what I ended up using in the event the addition operation exceeded Instant.DISTANT_FUTURE on jvm so that conversion on macosx64 works.

I see now it is documented on Instant.DISTANT_FUTURE, will close this issue as it's "expected" behavior.

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

No branches or pull requests

2 participants