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

Wrong answers in some cases when adding date-based units to instants on Darwin and Windows #51

Closed
dkhalanskyjb opened this issue Sep 11, 2020 · 0 comments
Assignees
Milestone

Comments

@dkhalanskyjb
Copy link
Collaborator

dkhalanskyjb commented Sep 11, 2020

There is a rare scenario where the result may be off (usually by an hour) when the result of an addition to an Instant is in a time overlap and the source Instant has the lesser offset of the two possible in the overlap. Then, the overlap is resolved incorrectly.

val zone = TimeZone.of("Europe/Berlin")
val instant1 = LocalDateTime(2019, Month.OCTOBER, 27, 2, 59).toInstant(zone)
val instant2 = LocalDateTime(2019, Month.OCTOBER, 28, 2, 59).toInstant(zone)
val instant3 = instant1.minus(300, DateTimeUnit.DAY, zone)
val instant4 = instant1.minus(10, DateTimeUnit.MONTH, zone)
assertEquals(instant1.plus(DateTimeUnit.HOUR), instant2.plus(-1, DateTimeUnit.DAY, zone))
assertEquals(instant1.plus(DateTimeUnit.HOUR), instant3.plus(300, DateTimeUnit.DAY, zone))
assertEquals(instant1.plus(DateTimeUnit.HOUR), instant4.plus(10, DateTimeUnit.MONTH, zone))

All these assertions fail on Darwin and Windows but pass in the other implementations (JVM, Unix, JS).

@dkhalanskyjb dkhalanskyjb self-assigned this Sep 11, 2020
dkhalanskyjb added a commit that referenced this issue Sep 11, 2020
@ilya-g ilya-g added this to the 0.1.1 milestone Nov 24, 2020
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