periodUntil

expect fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod

Returns a DateTimePeriod representing the difference between this and other instants.

The components of DateTimePeriod are calculated so that adding it to this instant results in the other instant.

All components of the DateTimePeriod returned are:

  • positive or zero if this instant is earlier than the other,

  • negative or zero if this instant is later than the other,

  • exactly zero if this instant is equal to the other.

Throws

if this or other instant is too large to fit in LocalDateTime. Or (only on the JVM) if the number of months between the two dates exceeds an Int.


expect fun LocalDate.periodUntil(other: LocalDate): DatePeriod

Returns a DatePeriod representing the difference between this and other dates.

The components of DatePeriod are calculated so that adding it to this date results in the other date.

All components of the DatePeriod returned are:

  • positive or zero if this date is earlier than the other,

  • negative or zero if this date is later than the other,

  • exactly zero if this date is equal to the other.

See also

Throws

if the number of months between the two dates exceeds an Int (JVM only).

actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod
actual fun LocalDate.periodUntil(other: LocalDate): DatePeriod
actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod
actual fun LocalDate.periodUntil(other: LocalDate): DatePeriod
actual fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateTimePeriod
actual fun LocalDate.periodUntil(other: LocalDate): DatePeriod