@@ -169,7 +169,7 @@ public actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Inst
169
169
val newLdt = toLocalDateTimeFailing(initialOffset)
170
170
.run { if (totalMonths != 0 ) { plus(totalMonths, DateTimeUnit .MONTH ) } else { this } }
171
171
.run { if (days != 0 ) { plus(days, DateTimeUnit .DAY ) } else { this } }
172
- timeZone.atZone (newLdt, preferred = initialOffset).toInstant( )
172
+ timeZone.localDateTimeToInstant (newLdt, preferred = initialOffset)
173
173
.run { if (totalNanoseconds != 0L ) plus(0 , totalNanoseconds).check(timeZone) else this }
174
174
}.check(timeZone)
175
175
} catch (e: ArithmeticException ) {
@@ -192,7 +192,7 @@ public actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZo
192
192
throw ArithmeticException (" Can't add a Long date-based value, as it would cause an overflow" )
193
193
val initialOffset = offsetIn(timeZone)
194
194
val initialLdt = toLocalDateTimeFailing(initialOffset)
195
- timeZone.atZone (initialLdt.plus(value.toInt(), unit), preferred = initialOffset).toInstant( )
195
+ timeZone.localDateTimeToInstant (initialLdt.plus(value.toInt(), unit), preferred = initialOffset)
196
196
}
197
197
is DateTimeUnit .TimeBased ->
198
198
check(timeZone).plus(value, unit).check(timeZone)
@@ -222,7 +222,7 @@ public actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateT
222
222
val months = initialLdt.until(otherLdt, DateTimeUnit .MONTH ).toLong().toInt() // `until` on dates never fails
223
223
val ldtWithMonths = initialLdt.plus(months, DateTimeUnit .MONTH ) // won't throw: thisLdt + months <= otherLdt, which is known to be valid
224
224
val days = ldtWithMonths.until(otherLdt, DateTimeUnit .DAY ).toLong().toInt() // `until` on dates never fails
225
- val newInstant = timeZone.atZone (ldtWithMonths.plus(days, DateTimeUnit .DAY ), preferred = initialOffset).toInstant( ) // won't throw: thisLdt + days <= otherLdt
225
+ val newInstant = timeZone.localDateTimeToInstant (ldtWithMonths.plus(days, DateTimeUnit .DAY ), preferred = initialOffset) // won't throw: thisLdt + days <= otherLdt
226
226
val nanoseconds = newInstant.until(other, DateTimeUnit .NANOSECOND ) // |otherLdt - thisLdt| < 24h
227
227
228
228
return buildDateTimePeriod(months, days, nanoseconds)
0 commit comments