@@ -140,18 +140,19 @@ private fun ZonedDateTime.plusNanosFix(nanoseconds: Long): ZonedDateTime {
140
140
}
141
141
}
142
142
143
- private fun jtInstant.atZone (zone : TimeZone ): ZonedDateTime = atZone(zone.zoneId)
143
+ private fun Instant.atZone (zone : TimeZone ): ZonedDateTime = value.atZone(zone.zoneId)
144
+ private fun jtInstant.checkZone (zone : TimeZone ): jtInstant = apply { atZone(zone.zoneId) }
144
145
145
146
public actual fun Instant.plus (unit : DateTimeUnit , zone : TimeZone ): Instant =
146
147
plus(1 , unit, zone)
147
148
148
149
public actual fun Instant.plus (value : Long , unit : DateTimeUnit , zone : TimeZone ): Instant =
149
150
try {
150
- val thisZdt = this .value. atZone(zone)
151
+ val thisZdt = this .atZone(zone)
151
152
when (unit) {
152
153
is DateTimeUnit .TimeBased -> {
153
154
multiplyAndDivide(value, unit.nanoseconds, NANOS_PER_ONE .toLong()).let {
154
- (d, r) -> this .plusFix(d.toDouble(), r.toInt()).also { it.atZone (zone.zoneId) }
155
+ (d, r) -> this .plusFix(d.toDouble(), r.toInt()).checkZone (zone)
155
156
}
156
157
}
157
158
is DateTimeUnit .DateBased .DayBased ->
@@ -166,11 +167,11 @@ public actual fun Instant.plus(value: Long, unit: DateTimeUnit, zone: TimeZone):
166
167
167
168
public actual fun Instant.plus (value : Int , unit : DateTimeUnit , zone : TimeZone ): Instant =
168
169
try {
169
- val thisZdt = this .value. atZone(zone)
170
+ val thisZdt = this .atZone(zone)
170
171
when (unit) {
171
172
is DateTimeUnit .TimeBased -> {
172
173
multiplyAndDivide(value.toLong(), unit.nanoseconds, NANOS_PER_ONE .toLong()).let {
173
- (d, r) -> this .plusFix(d.toDouble(), r.toInt()).also { it.atZone (zone.zoneId) }
174
+ (d, r) -> this .plusFix(d.toDouble(), r.toInt()).checkZone (zone)
174
175
}
175
176
}
176
177
is DateTimeUnit .DateBased .DayBased ->
@@ -200,8 +201,8 @@ public actual fun Instant.periodUntil(other: Instant, zone: TimeZone): DateTimeP
200
201
}
201
202
202
203
public actual fun Instant.until (other : Instant , unit : DateTimeUnit , zone : TimeZone ): Long = try {
203
- val thisZdt = this .value. atZone(zone)
204
- val otherZdt = other.value. atZone(zone)
204
+ val thisZdt = this .atZone(zone)
205
+ val otherZdt = other.atZone(zone)
205
206
when (unit) {
206
207
is DateTimeUnit .TimeBased -> {
207
208
multiplyAddAndDivide(other.epochSeconds - epochSeconds,
0 commit comments