@@ -271,7 +271,7 @@ public actual fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Inst
271
271
val newLdt = toLocalDateTimeFailing(initialOffset)
272
272
.run { if (totalMonths != 0 ) { plus(totalMonths, DateTimeUnit .MONTH ) } else { this } }
273
273
.run { if (days != 0 ) { plus(days, DateTimeUnit .DAY ) } else { this } }
274
- timeZone.atZone (newLdt, preferred = initialOffset).toInstant( )
274
+ timeZone.localDateTimeToInstant (newLdt, preferred = initialOffset)
275
275
.run { if (totalNanoseconds != 0L ) plus(0 , totalNanoseconds).check(timeZone) else this }
276
276
}.check(timeZone)
277
277
} catch (e: ArithmeticException ) {
@@ -294,7 +294,7 @@ public actual fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZo
294
294
throw ArithmeticException (" Can't add a Long date-based value, as it would cause an overflow" )
295
295
val initialOffset = offsetIn(timeZone)
296
296
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)
298
298
}
299
299
is DateTimeUnit .TimeBased ->
300
300
check(timeZone).plus(value, unit).check(timeZone)
@@ -324,7 +324,7 @@ public actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateT
324
324
val months = initialLdt.until(otherLdt, DateTimeUnit .MONTH ).toLong().toInt() // `until` on dates never fails
325
325
val ldtWithMonths = initialLdt.plus(months, DateTimeUnit .MONTH ) // won't throw: thisLdt + months <= otherLdt, which is known to be valid
326
326
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
328
328
val nanoseconds = newInstant.until(other, DateTimeUnit .NANOSECOND ) // |otherLdt - thisLdt| < 24h
329
329
330
330
return buildDateTimePeriod(months, days, nanoseconds)
0 commit comments