@@ -56,8 +56,8 @@ import kotlin.time.*
56
56
* ```
57
57
*
58
58
* For values very far in the past or the future, this conversion may fail.
59
- * The specific range of values that can be converted to [LocalDateTime] is platform-specific , but at least
60
- * [DISTANT_PAST], [DISTANT_FUTURE], and all values between them can be converted to [LocalDateTime] .
59
+ * The specific range of values that can be converted to [LocalDateTime] is unspecified , but at least
60
+ * [DISTANT_PAST], [DISTANT_FUTURE], and all values between them are included in that range .
61
61
*
62
62
* #### Date or time separately
63
63
*
@@ -225,7 +225,8 @@ public expect class Instant : Comparable<Instant> {
225
225
*
226
226
* Any fractional part of a millisecond is rounded toward zero to the whole number of milliseconds.
227
227
*
228
- * If the result does not fit in [Long], returns [Long.MAX_VALUE] for a positive result or [Long.MIN_VALUE] for a negative result.
228
+ * If the result does not fit in [Long],
229
+ * returns [Long.MAX_VALUE] for a positive result or [Long.MIN_VALUE] for a negative result.
229
230
*
230
231
* @see fromEpochMilliseconds
231
232
* @sample kotlinx.datetime.test.samples.InstantSamples.toEpochMilliseconds
@@ -238,7 +239,7 @@ public expect class Instant : Comparable<Instant> {
238
239
* If the [duration] is positive, the returned instant is later than this instant.
239
240
* If the [duration] is negative, the returned instant is earlier than this instant.
240
241
*
241
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
242
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
242
243
*
243
244
* **Pitfall**: [Duration.Companion.days] are multiples of 24 hours and are not calendar-based.
244
245
* Consider using the [plus] overload that accepts a multiple of a [DateTimeUnit] instead for calendar-based
@@ -255,7 +256,7 @@ public expect class Instant : Comparable<Instant> {
255
256
* If the [duration] is positive, the returned instant is earlier than this instant.
256
257
* If the [duration] is negative, the returned instant is later than this instant.
257
258
*
258
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
259
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
259
260
*
260
261
* **Pitfall**: [Duration.Companion.days] are multiples of 24 hours and are not calendar-based.
261
262
* Consider using the [minus] overload that accepts a multiple of a [DateTimeUnit] instead for calendar-based
@@ -319,8 +320,7 @@ public expect class Instant : Comparable<Instant> {
319
320
/* *
320
321
* Returns an [Instant] that is [epochMilliseconds] number of milliseconds from the epoch instant `1970-01-01T00:00:00Z`.
321
322
*
322
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
323
- * In any case, it is guaranteed that instants between [DISTANT_PAST] and [DISTANT_FUTURE] can be represented.
323
+ * Every value of [epochMilliseconds] is guaranteed to be representable as an [Instant].
324
324
*
325
325
* Note that [Instant] also supports nanosecond precision via [fromEpochSeconds].
326
326
*
@@ -333,7 +333,7 @@ public expect class Instant : Comparable<Instant> {
333
333
* Returns an [Instant] that is the [epochSeconds] number of seconds from the epoch instant `1970-01-01T00:00:00Z`
334
334
* and the [nanosecondAdjustment] number of nanoseconds from the whole second.
335
335
*
336
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
336
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
337
337
* In any case, it is guaranteed that instants between [DISTANT_PAST] and [DISTANT_FUTURE] can be represented.
338
338
*
339
339
* [fromEpochMilliseconds] is a similar function for when input data only has millisecond precision.
@@ -348,7 +348,7 @@ public expect class Instant : Comparable<Instant> {
348
348
* Returns an [Instant] that is the [epochSeconds] number of seconds from the epoch instant `1970-01-01T00:00:00Z`
349
349
* and the [nanosecondAdjustment] number of nanoseconds from the whole second.
350
350
*
351
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
351
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
352
352
* In any case, it is guaranteed that instants between [DISTANT_PAST] and [DISTANT_FUTURE] can be represented.
353
353
*
354
354
* [fromEpochMilliseconds] is a similar function for when input data only has millisecond precision.
@@ -389,7 +389,7 @@ public expect class Instant : Comparable<Instant> {
389
389
* An instant value that is far in the past.
390
390
*
391
391
* All instants in the range `DISTANT_PAST..DISTANT_FUTURE` can be [converted][Instant.toLocalDateTime] to
392
- * [LocalDateTime] without exceptions in every time zone on all supported platforms .
392
+ * [LocalDateTime] without exceptions in every time zone.
393
393
*
394
394
* [isDistantPast] returns true for this value and all earlier ones.
395
395
*/
@@ -399,7 +399,7 @@ public expect class Instant : Comparable<Instant> {
399
399
* An instant value that is far in the future.
400
400
*
401
401
* All instants in the range `DISTANT_PAST..DISTANT_FUTURE` can be [converted][Instant.toLocalDateTime] to
402
- * [LocalDateTime] without exceptions in every time zone on all supported platforms .
402
+ * [LocalDateTime] without exceptions in every time zone.
403
403
*
404
404
* [isDistantFuture] returns true for this value and all later ones.
405
405
*/
@@ -467,7 +467,7 @@ public expect fun Instant.plus(period: DateTimePeriod, timeZone: TimeZone): Inst
467
467
public fun Instant.minus (period : DateTimePeriod , timeZone : TimeZone ): Instant =
468
468
/* An overflow can happen for any component, but we are only worried about nanoseconds, as having an overflow in
469
469
any other component means that `plus` will throw due to the minimum value of the numeric type overflowing the
470
- platform-specific limits. */
470
+ `Instant` limits. */
471
471
if (period.totalNanoseconds != Long .MIN_VALUE ) {
472
472
val negatedPeriod = with (period) { buildDateTimePeriod(- totalMonths, - days, - totalNanoseconds) }
473
473
plus(negatedPeriod, timeZone)
@@ -487,7 +487,6 @@ public fun Instant.minus(period: DateTimePeriod, timeZone: TimeZone): Instant =
487
487
* - Exactly zero if this instant is equal to the other.
488
488
*
489
489
* @throws DateTimeArithmeticException if `this` or [other] instant is too large to fit in [LocalDateTime].
490
- * Or (only on the JVM) if the number of months between the two dates exceeds an Int.
491
490
* @sample kotlinx.datetime.test.samples.InstantSamples.periodUntil
492
491
*/
493
492
public expect fun Instant.periodUntil (other : Instant , timeZone : TimeZone ): DateTimePeriod
@@ -526,7 +525,7 @@ public fun Instant.until(other: Instant, unit: DateTimeUnit.TimeBased): Long =
526
525
NANOS_PER_ONE .toLong(),
527
526
(other.nanosecondsOfSecond - nanosecondsOfSecond).toLong(),
528
527
unit.nanoseconds)
529
- } catch (e : ArithmeticException ) {
528
+ } catch (_ : ArithmeticException ) {
530
529
if (this < other) Long .MAX_VALUE else Long .MIN_VALUE
531
530
}
532
531
@@ -577,7 +576,6 @@ public fun Instant.yearsUntil(other: Instant, timeZone: TimeZone): Int =
577
576
* - Exactly zero if this instant is equal to the other.
578
577
*
579
578
* @throws DateTimeArithmeticException if `this` or [other] instant is too large to fit in [LocalDateTime].
580
- * Or (only on the JVM) if the number of months between the two dates exceeds an Int.
581
579
* @see Instant.periodUntil
582
580
* @sample kotlinx.datetime.test.samples.InstantSamples.minusInstantInZone
583
581
*/
@@ -613,7 +611,7 @@ public fun Instant.minus(unit: DateTimeUnit, timeZone: TimeZone): Instant =
613
611
*
614
612
* The returned instant is later than this instant.
615
613
*
616
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
614
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
617
615
*/
618
616
@Deprecated(" Use the plus overload with an explicit number of units" , ReplaceWith (" this.plus(1, unit)" ))
619
617
public fun Instant.plus (unit : DateTimeUnit .TimeBased ): Instant =
@@ -624,7 +622,7 @@ public fun Instant.plus(unit: DateTimeUnit.TimeBased): Instant =
624
622
*
625
623
* The returned instant is earlier than this instant.
626
624
*
627
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
625
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
628
626
*/
629
627
@Deprecated(" Use the minus overload with an explicit number of units" , ReplaceWith (" this.minus(1, unit)" ))
630
628
public fun Instant.minus (unit : DateTimeUnit .TimeBased ): Instant =
@@ -669,7 +667,7 @@ public expect fun Instant.minus(value: Int, unit: DateTimeUnit, timeZone: TimeZo
669
667
* If the [value] is positive, the returned instant is later than this instant.
670
668
* If the [value] is negative, the returned instant is earlier than this instant.
671
669
*
672
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
670
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
673
671
*
674
672
* @sample kotlinx.datetime.test.samples.InstantSamples.plusTimeBasedUnit
675
673
*/
@@ -682,7 +680,7 @@ public fun Instant.plus(value: Int, unit: DateTimeUnit.TimeBased): Instant =
682
680
* If the [value] is positive, the returned instant is earlier than this instant.
683
681
* If the [value] is negative, the returned instant is later than this instant.
684
682
*
685
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
683
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
686
684
*
687
685
* @sample kotlinx.datetime.test.samples.InstantSamples.minusTimeBasedUnit
688
686
*/
@@ -730,7 +728,7 @@ public fun Instant.minus(value: Long, unit: DateTimeUnit, timeZone: TimeZone): I
730
728
* If the [value] is positive, the returned instant is later than this instant.
731
729
* If the [value] is negative, the returned instant is earlier than this instant.
732
730
*
733
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
731
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
734
732
*
735
733
* @sample kotlinx.datetime.test.samples.InstantSamples.plusTimeBasedUnit
736
734
*/
@@ -742,7 +740,7 @@ public expect fun Instant.plus(value: Long, unit: DateTimeUnit.TimeBased): Insta
742
740
* If the [value] is positive, the returned instant is earlier than this instant.
743
741
* If the [value] is negative, the returned instant is later than this instant.
744
742
*
745
- * The return value is clamped to the platform-specific boundaries for [Instant] if the result exceeds them.
743
+ * The return value is clamped to the boundaries of [Instant] if the result exceeds them.
746
744
*
747
745
* @sample kotlinx.datetime.test.samples.InstantSamples.minusTimeBasedUnit
748
746
*/
0 commit comments