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

Native (Kotlin): Fix a bug with Instant.plus #3

Merged
merged 2 commits into from
Apr 28, 2020
Merged

Conversation

dkhalanskyjb
Copy link
Collaborator

There was a problem with Instant.plus failing to adjust an
intermediate date due to offset changing. This led to behaviour
different from other platforms and plus and periodUntil not
being inverse operations.

@dkhalanskyjb dkhalanskyjb requested a review from ilya-g April 24, 2020 14:08
@@ -202,24 +202,24 @@ actual fun Instant.plus(period: CalendarPeriod, zone: TimeZone): Instant {
minutes.toLong() * SECONDS_PER_MINUTE,
hours.toLong() * SECONDS_PER_HOUR))
}
val localDateTime = toLocalDateTime(zone)
val localDateTime = with (zone) { toZonedLocalDateTime() }
Copy link
Member

Choose a reason for hiding this comment

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

For internal use it might be clearer to introduce top level extension Instant.toZonedDateTime(zone).
Member extensions inside TimeZone are somewhat experimental.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed.

There was a problem with `Instant.plus` failing to adjust an
intermediate date due to offset changing. This led to behaviour
different from other platforms and `plus` and `periodUntil` not
being inverse operations.
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.

2 participants