@@ -173,6 +173,15 @@ public fun String.toInstant(): Instant = Instant.parse(this)
173
173
*/
174
174
public expect fun Instant.plus (period : DateTimePeriod , timeZone : TimeZone ): Instant
175
175
176
+ /* *
177
+ * Returns an instant that is the result of subtracting components of [DateTimePeriod] from this instant. The components
178
+ * are subtracted in the order from the largest units to the smallest, i.e. from years to nanoseconds.
179
+ *
180
+ * @throws DateTimeArithmeticException if this value or the results of intermediate computations are too large to fit in
181
+ * [LocalDateTime].
182
+ */
183
+ public fun Instant.minus (period : DateTimePeriod , timeZone : TimeZone ): Instant = plus(- period, timeZone)
184
+
176
185
/* *
177
186
* Returns a [DateTimePeriod] representing the difference between `this` and [other] instants.
178
187
*
@@ -282,6 +291,17 @@ public fun Instant.minus(other: Instant, timeZone: TimeZone): DateTimePeriod =
282
291
*/
283
292
public expect fun Instant.plus (unit : DateTimeUnit , timeZone : TimeZone ): Instant
284
293
294
+ /* *
295
+ * Returns an instant that is the result of subtracting one [unit] from this instant
296
+ * in the specified [timeZone].
297
+ *
298
+ * The returned instant is earlier than this instant.
299
+ *
300
+ * @throws DateTimeArithmeticException if this value or the result is too large to fit in [LocalDateTime].
301
+ */
302
+ public fun Instant.minus (unit : DateTimeUnit , timeZone : TimeZone ): Instant =
303
+ plus(- 1 , unit, timeZone)
304
+
285
305
/* *
286
306
* Returns an instant that is the result of adding one [unit] to this instant.
287
307
*
@@ -292,6 +312,16 @@ public expect fun Instant.plus(unit: DateTimeUnit, timeZone: TimeZone): Instant
292
312
public fun Instant.plus (unit : DateTimeUnit .TimeBased ): Instant =
293
313
plus(1L , unit)
294
314
315
+ /* *
316
+ * Returns an instant that is the result of subtracting one [unit] from this instant.
317
+ *
318
+ * The returned instant is earlier than this instant.
319
+ *
320
+ * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
321
+ */
322
+ public fun Instant.minus (unit : DateTimeUnit .TimeBased ): Instant =
323
+ plus(- 1L , unit)
324
+
295
325
/* *
296
326
* Returns an instant that is the result of adding the [value] number of the specified [unit] to this instant
297
327
* in the specified [timeZone].
@@ -303,6 +333,18 @@ public fun Instant.plus(unit: DateTimeUnit.TimeBased): Instant =
303
333
*/
304
334
public expect fun Instant.plus (value : Int , unit : DateTimeUnit , timeZone : TimeZone ): Instant
305
335
336
+ /* *
337
+ * Returns an instant that is the result of subtracting the [value] number of the specified [unit] from this instant
338
+ * in the specified [timeZone].
339
+ *
340
+ * If the [value] is positive, the returned instant is earlier than this instant.
341
+ * If the [value] is negative, the returned instant is later than this instant.
342
+ *
343
+ * @throws DateTimeArithmeticException if this value or the result is too large to fit in [LocalDateTime].
344
+ */
345
+ public fun Instant.minus (value : Int , unit : DateTimeUnit , timeZone : TimeZone ): Instant =
346
+ plus(- value, unit, timeZone)
347
+
306
348
/* *
307
349
* Returns an instant that is the result of adding the [value] number of the specified [unit] to this instant.
308
350
*
@@ -314,6 +356,17 @@ public expect fun Instant.plus(value: Int, unit: DateTimeUnit, timeZone: TimeZon
314
356
public fun Instant.plus (value : Int , unit : DateTimeUnit .TimeBased ): Instant =
315
357
plus(value.toLong(), unit)
316
358
359
+ /* *
360
+ * Returns an instant that is the result of subtracting the [value] number of the specified [unit] from this instant.
361
+ *
362
+ * If the [value] is positive, the returned instant is earlier than this instant.
363
+ * If the [value] is negative, the returned instant is later than this instant.
364
+ *
365
+ * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
366
+ */
367
+ public fun Instant.minus (value : Int , unit : DateTimeUnit .TimeBased ): Instant =
368
+ plus(- value.toLong(), unit)
369
+
317
370
/* *
318
371
* Returns an instant that is the result of adding the [value] number of the specified [unit] to this instant
319
372
* in the specified [timeZone].
@@ -325,6 +378,17 @@ public fun Instant.plus(value: Int, unit: DateTimeUnit.TimeBased): Instant =
325
378
*/
326
379
public expect fun Instant.plus (value : Long , unit : DateTimeUnit , timeZone : TimeZone ): Instant
327
380
381
+ /* *
382
+ * Returns an instant that is the result of subtracting the [value] number of the specified [unit] from this instant
383
+ * in the specified [timeZone].
384
+ *
385
+ * If the [value] is positive, the returned instant is earlier than this instant.
386
+ * If the [value] is negative, the returned instant is later than this instant.
387
+ *
388
+ * @throws DateTimeArithmeticException if this value or the result is too large to fit in [LocalDateTime].
389
+ */
390
+ public fun Instant.minus (value : Long , unit : DateTimeUnit , timeZone : TimeZone ) = plus(- value, unit, timeZone)
391
+
328
392
/* *
329
393
* Returns an instant that is the result of adding the [value] number of the specified [unit] to this instant.
330
394
*
@@ -335,6 +399,16 @@ public expect fun Instant.plus(value: Long, unit: DateTimeUnit, timeZone: TimeZo
335
399
*/
336
400
public expect fun Instant.plus (value : Long , unit : DateTimeUnit .TimeBased ): Instant
337
401
402
+ /* *
403
+ * Returns an instant that is the result of subtracting the [value] number of the specified [unit] from this instant.
404
+ *
405
+ * If the [value] is positive, the returned instant is earlier than this instant.
406
+ * If the [value] is negative, the returned instant is later than this instant.
407
+ *
408
+ * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
409
+ */
410
+ public fun Instant.minus (value : Long , unit : DateTimeUnit .TimeBased ): Instant = plus(- value, unit)
411
+
338
412
/* *
339
413
* Returns the whole number of the specified date or time [units][unit] between [other] and `this` instants
340
414
* in the specified [timeZone].
0 commit comments