@@ -271,7 +271,7 @@ public actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Inst
271271 val newLdt = toLocalDateTimeFailing(initialOffset)
272272 .run { if (totalMonths != 0 ) { plus(totalMonths, DateTimeUnit .MONTH ) } else { this } }
273273 .run { if (days != 0 ) { plus(days, DateTimeUnit .DAY ) } else { this } }
274- timeZone.atZone (newLdt, preferred = initialOffset).toInstant( )
274+ timeZone.localDateTimeToInstant (newLdt, preferred = initialOffset)
275275 .run { if (totalNanoseconds != 0L ) plus(0 , totalNanoseconds).check(timeZone) else this }
276276 }.check(timeZone)
277277} catch (e: ArithmeticException ) {
@@ -294,7 +294,7 @@ public actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZo
294294 throw ArithmeticException (" Can't add a Long date-based value, as it would cause an overflow" )
295295 val initialOffset = offsetIn(timeZone)
296296 val initialLdt = toLocalDateTimeFailing(initialOffset)
297- timeZone.atZone (initialLdt.plus(value.toInt(), unit), preferred = initialOffset).toInstant( )
297+ timeZone.localDateTimeToInstant (initialLdt.plus(value.toInt(), unit), preferred = initialOffset)
298298 }
299299 is DateTimeUnit .TimeBased ->
300300 check(timeZone).plus(value, unit).check(timeZone)
@@ -324,7 +324,7 @@ public actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateT
324324 val months = initialLdt.until(otherLdt, DateTimeUnit .MONTH ).toLong().toInt() // `until` on dates never fails
325325 val ldtWithMonths = initialLdt.plus(months, DateTimeUnit .MONTH ) // won't throw: thisLdt + months <= otherLdt, which is known to be valid
326326 val days = ldtWithMonths.until(otherLdt, DateTimeUnit .DAY ).toLong().toInt() // `until` on dates never fails
327- val newInstant = timeZone.atZone (ldtWithMonths.plus(days, DateTimeUnit .DAY ), preferred = initialOffset).toInstant( ) // won't throw: thisLdt + days <= otherLdt
327+ val newInstant = timeZone.localDateTimeToInstant (ldtWithMonths.plus(days, DateTimeUnit .DAY ), preferred = initialOffset) // won't throw: thisLdt + days <= otherLdt
328328 val nanoseconds = newInstant.until(other, DateTimeUnit .NANOSECOND ) // |otherLdt - thisLdt| < 24h
329329
330330 return buildDateTimePeriod(months, days, nanoseconds)
0 commit comments