core / io.islandtime.ranges

Package io.islandtime.ranges

Date ranges, time intervals, and the ability to iterate over them and perform various operations.

Types

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DateDayProgression

open class DateDayProgression : Iterable<Date>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DateIterator

abstract class DateIterator : Iterator<Date>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DateMonthProgression

class DateMonthProgression : Iterable<Date>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DateRange

An inclusive range of dates.

class DateRange : DateDayProgression, ClosedRange<Date>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DateTimeInterval

An interval between two date-times, assumed to be at the same offset from UTC.

class DateTimeInterval : TimeInterval<DateTime>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

InstantInterval

A half-open interval between two instants.

class InstantInterval : TimePointInterval<Instant>, TimePointProgressionBuilder<Instant>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

OffsetDateTimeInterval

A half-open interval between two offset date-times based on timeline order.

class OffsetDateTimeInterval : TimePointInterval<OffsetDateTime>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimeInterval

A half-open time interval.

interface TimeInterval<T>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimePointInterval

A half-open interval of time points.

abstract class TimePointInterval<T : TimePoint<T>> : TimeInterval<T>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimePointIterator

abstract class TimePointIterator<T : TimePoint<T>> : Iterator<T>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimePointNanosecondProgression

class TimePointNanosecondProgression<T : TimePoint<T>> : TimePointProgressionBuilder<T>, Iterable<T>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimePointProgressionBuilder

A time point progression builder.

interface TimePointProgressionBuilder<T : TimePoint<T>>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimePointSecondProgression

class TimePointSecondProgression<T : TimePoint<T>> : TimePointProgressionBuilder<T>, Iterable<T>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

ZonedDateTimeInterval

A half-open interval of zoned date-times based on timeline order.

class ZonedDateTimeInterval : TimePointInterval<ZonedDateTime>

Extensions for External Classes

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

kotlin.String

Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asInstantInterval

fun OffsetDateTimeInterval.asInstantInterval(): InstantInterval
fun ZonedDateTimeInterval.asInstantInterval(): InstantInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asZonedDateTimeInterval

Converts this interval to an equivalent ZonedDateTimeInterval where both endpoints are given a fixed-offset time zone.

fun OffsetDateTimeInterval.asZonedDateTimeInterval(): ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

at

Combines this DateRange with a TimeZone to create a ZonedDateTimeInterval between the start of the first day and the end of the last day in zone.

infix fun DateRange.at(zone: TimeZone): ZonedDateTimeInterval

Combines this DateTimeInterval with a TimeZone to create a ZonedDateTimeInterval where both endpoints are in zone.

infix fun DateTimeInterval.at(zone: TimeZone): ZonedDateTimeInterval

Combines this InstantInterval with a TimeZone to create an equivalent ZonedDateTimeInterval where both endpoints are in zone.

infix fun InstantInterval.at(zone: TimeZone): ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

daysBetween

Get the number of days between two dates.

fun daysBetween(start: Date, endExclusive: Date): LongDays

Get the number whole days between two date-times, assuming they're in the same time zone.

fun daysBetween(start: DateTime, endExclusive: DateTime): LongDays

Get the number whole days between two date-times, adjusting the offset of endExclusive if necessary to match the starting date-time.

fun daysBetween(start: OffsetDateTime, endExclusive: OffsetDateTime): LongDays

Get the number of 24-hour days between two time points.

fun <T1, T2> daysBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongDays

Get the number of whole days between two zoned date-times, adjusting the time zone of endExclusive if necessary to match the starting date-time.

fun daysBetween(start: ZonedDateTime, endExclusive: ZonedDateTime): LongDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

downTo

A get progression of dates in descending order

infix fun Date.downTo(to: Date): DateDayProgression

Get a progression of time points in descending order.

infix fun <T : TimePoint<T>> T.downTo(to: T): TimePointProgressionBuilder<T>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

durationBetween

Get the Duration between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun durationBetween(start: DateTime, endExclusive: DateTime): Duration

Get the Duration between two time points.

fun <T1, T2> durationBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): Duration
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

hoursBetween

Get the number of whole hours between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun hoursBetween(start: DateTime, endExclusive: DateTime): LongHours

Get the number of whole hours between two time points.

fun <T1, T2> hoursBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongHours
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

microsecondsBetween

Get the number of whole microseconds between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun microsecondsBetween(start: DateTime, endExclusive: DateTime): LongMicroseconds

Get the number of whole microseconds between two time points.

fun <T1, T2> microsecondsBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongMicroseconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

millisecondsBetween

Get the number of whole milliseconds between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun millisecondsBetween(start: DateTime, endExclusive: DateTime): LongMilliseconds

Get the number of whole milliseconds between two time points.

fun <T1, T2> millisecondsBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongMilliseconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

minutesBetween

Get the number of whole minutes between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun minutesBetween(start: DateTime, endExclusive: DateTime): LongMinutes

Get the number of whole minutes between two time points.

fun <T1, T2> minutesBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongMinutes
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

monthsBetween

Get the number of whole months between two dates.

fun monthsBetween(start: Date, endExclusive: Date): IntMonths

Get the number of whole months between two date-times, assuming they're in the same time zone.

fun monthsBetween(start: DateTime, endExclusive: DateTime): IntMonths

Get the number of whole months between two date-times, adjusting the offset of endExclusive if necessary to match the starting date-time.

fun monthsBetween(start: OffsetDateTime, endExclusive: OffsetDateTime): IntMonths

Get the number of whole months between two zoned date-times, adjusting the time zone of endExclusive if necessary to match the starting date-time.

fun monthsBetween(start: ZonedDateTime, endExclusive: ZonedDateTime): IntMonths
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

nanosecondsBetween

Get the number of nanoseconds between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun nanosecondsBetween(start: DateTime, endExclusive: DateTime): LongNanoseconds

Get the number of nanoseconds between two time points.

fun <T1, T2> nanosecondsBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongNanoseconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

periodBetween

Get the Period between two dates.

fun periodBetween(start: Date, endExclusive: Date): Period

Get the Period between two date-times, assuming they're in the same time zone.

fun periodBetween(start: DateTime, endExclusive: DateTime): Period

Get the Period between two date-times, adjusting the offset of endExclusive if necessary to match the starting date-time.

fun periodBetween(start: OffsetDateTime, endExclusive: OffsetDateTime): Period

Get the Period between two zoned date-times, adjusting the time zone of endExclusive if necessary to match the starting date-time.

fun periodBetween(start: ZonedDateTime, endExclusive: ZonedDateTime): Period

random

Return a random date within the range using the supplied random number generator.

(jvm) fun DateRange.random(random: Random): Date
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateRange.random(random: <ERROR CLASS>): Date

Return a random date-time within the interval using the supplied random number generator.

(jvm) fun DateTimeInterval.random(random: Random): DateTime
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateTimeInterval.random(random: <ERROR CLASS>): DateTime

Return a random instant within the interval using the supplied random number generator.

(jvm) fun InstantInterval.random(random: Random): Instant
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun InstantInterval.random(random: <ERROR CLASS>): Instant

Return a random date-time within the interval using the supplied random number generator. The offset of the start date-time will be used.

(jvm) fun OffsetDateTimeInterval.random(random: Random): OffsetDateTime
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun OffsetDateTimeInterval.random(random: <ERROR CLASS>): OffsetDateTime

Return a random date-time within the interval using the supplied random number generator. The zone of the start date-time will be used.

(jvm) fun ZonedDateTimeInterval.random(random: Random): ZonedDateTime
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun ZonedDateTimeInterval.random(random: <ERROR CLASS>): ZonedDateTime

Return a random date within the range using the default random number generator.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateRange.random(): Date

Return a random date-time within the interval using the default random number generator.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateTimeInterval.random(): DateTime

Return a random instant within the interval using the default random number generator.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun InstantInterval.random(): Instant

Return a random date-time within the interval using the default random number generator. The offset of the start date-time will be used.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun OffsetDateTimeInterval.random(): OffsetDateTime

Return a random date-time within the interval using the default random number generator. The zone of the start date-time will be used.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun ZonedDateTimeInterval.random(): ZonedDateTime

randomOrNull

Return a random date within the range using the supplied random number generator or null if the range is empty or unbounded.

(jvm) fun DateRange.randomOrNull(random: Random): Date?
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateRange.randomOrNull(random: <ERROR CLASS>): Date?

Return a random date-time within the interval using the supplied random number generator or null if the interval is empty or unbounded.

(jvm) fun DateTimeInterval.randomOrNull(random: Random): DateTime?
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateTimeInterval.randomOrNull(random: <ERROR CLASS>): DateTime?

Return a random instant within the interval using the supplied random number generator or null if the interval is empty or unbounded.

(jvm) fun InstantInterval.randomOrNull(random: Random): Instant?
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun InstantInterval.randomOrNull(random: <ERROR CLASS>): Instant?

Return a random date-time within the interval using the supplied random number generator or null if the interval is empty or unbounded. The offset of the start date-time will be used.

(jvm) fun OffsetDateTimeInterval.randomOrNull(random: Random): OffsetDateTime?
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun OffsetDateTimeInterval.randomOrNull(random: <ERROR CLASS>): OffsetDateTime?

Return a random date-time within the interval using the supplied random number generator or null if the interval is empty or unbounded. The zone of the start date-time will be used.

(jvm) fun ZonedDateTimeInterval.randomOrNull(random: Random): ZonedDateTime?
(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun ZonedDateTimeInterval.randomOrNull(random: <ERROR CLASS>): ZonedDateTime?

Return a random date within the range using the default random number generator or null if the range is empty or unbounded.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateRange.randomOrNull(): Date?

Return a random date-time within the interval using the default random number generator or null if the interval is empty or unbounded.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun DateTimeInterval.randomOrNull(): DateTime?

Return a random instant within the interval using the default random number generator or null if the interval is empty or unbounded.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun InstantInterval.randomOrNull(): Instant?

Return a random date-time within the interval using the default random number generator or null if the interval is empty or unbounded. The offset of the start date-time will be used.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun OffsetDateTimeInterval.randomOrNull(): OffsetDateTime?

Return a random date-time within the interval using the default random number generator or null if the interval is empty or unbounded. The zone of the start date-time will be used.

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun ZonedDateTimeInterval.randomOrNull(): ZonedDateTime?
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

reversed

Reverse a progression such that it counts down instead of up, or vice versa

fun DateDayProgression.reversed(): DateDayProgressionfun DateMonthProgression.reversed(): DateMonthProgression
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

secondsBetween

Get the number of whole seconds between two date-times, assuming they have the same UTC offset. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

fun secondsBetween(start: DateTime, endExclusive: DateTime): LongSeconds

Get the number of whole seconds between two time points.

fun <T1, T2> secondsBetween(start: TimePoint<T1>, endExclusive: TimePoint<T2>): LongSeconds
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

step

Step over dates in increments of days

infix fun DateDayProgression.step(step: IntDays): DateDayProgressioninfix fun DateDayProgression.step(step: IntWeeks): DateDayProgression
infix fun DateDayProgression.step(step: IntYears): DateMonthProgression
infix fun DateDayProgression.step(step: IntDecades): DateMonthProgression
infix fun DateDayProgression.step(step: IntCenturies): DateMonthProgression
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntDays): TimePointSecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntHours): TimePointSecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntMinutes): TimePointSecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntSeconds): TimePointSecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntMilliseconds): TimePointNanosecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: LongMilliseconds): TimePointNanosecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntMicroseconds): TimePointNanosecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: LongMicroseconds): TimePointNanosecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: IntNanoseconds): TimePointNanosecondProgression<T>
infix fun <T : TimePoint<T>> TimePointProgressionBuilder<T>.step(step: LongNanoseconds): TimePointNanosecondProgression<T>

Step over dates in increments of months

infix fun DateDayProgression.step(step: IntMonths): DateMonthProgression
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toDateRange

Returns this interval with the precision reduced to just the date.

fun DateTimeInterval.toDateRange(): DateRange
fun OffsetDateTimeInterval.toDateRange(): DateRange
fun ZonedDateTimeInterval.toDateRange(): DateRange
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toDateRangeAt

Converts this interval to the equivalent DateRange when both endpoints are in zone.

fun InstantInterval.toDateRangeAt(zone: TimeZone): DateRange
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toDateTimeInterval

Returns this interval with the precision reduced to only the local date and time.

fun OffsetDateTimeInterval.toDateTimeInterval(): DateTimeInterval
fun ZonedDateTimeInterval.toDateTimeInterval(): DateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toDateTimeIntervalAt

Converts this interval to the equivalent DateTimeInterval when both endpoints are in zone.

fun InstantInterval.toDateTimeIntervalAt(zone: TimeZone): DateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toInstantInterval

Converts this interval to an InstantInterval.

fun OffsetDateTimeInterval.toInstantInterval(): InstantInterval
fun ZonedDateTimeInterval.toInstantInterval(): InstantInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toInstantIntervalAt

Converts this range to an InstantInterval between the start of the first day and the end of the last day in zone.

fun DateRange.toInstantIntervalAt(zone: TimeZone): InstantInterval

Converts this interval to an InstantInterval where both endpoints are in zone.

fun DateTimeInterval.toInstantIntervalAt(zone: TimeZone): InstantInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toOffsetDateTimeInterval

Converts this interval to an OffsetDateTimeInterval.

fun ZonedDateTimeInterval.toOffsetDateTimeInterval(): OffsetDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toZonedDateTimeInterval

Converts this interval to a ZonedDateTimeInterval using the specified strategy to adjust each endpoint to a valid date, time, and offset in zone.

fun OffsetDateTimeInterval.toZonedDateTimeInterval(zone: TimeZone, strategy: OffsetConversionStrategy): ZonedDateTimeInterval

Convert a range of dates into a ZonedDateTimeInterval between the starting and ending instants in a particular time zone.

fun DateRange.toZonedDateTimeInterval(zone: TimeZone): ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

until

Get a range containing all of the days up to, but not including to.

infix fun Date.until(to: Date): DateRange

Get an interval containing all of the date-times up to, but not including the nanosecond represented by to.

infix fun DateTime.until(to: DateTime): DateTimeInterval

Get an interval containing all of the instants up to, but not including to.

infix fun Instant.until(to: Instant): InstantInterval

Create an interval containing all of the representable date-times from up to, but not including to.

infix fun OffsetDateTime.until(to: OffsetDateTime): OffsetDateTimeInterval

Get an interval containing all of the representable time points up to, but not including to.

infix fun ZonedDateTime.until(to: ZonedDateTime): ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

weeksBetween

Get the number of whole weeks between two dates.

fun weeksBetween(start: Date, endExclusive: Date): LongWeeks

Get the number whole weeks between two date-times, assuming they're in the same time zone.

fun weeksBetween(start: DateTime, endExclusive: DateTime): LongWeeks

Get the number whole weeks between two date-times, adjusting the offset of endExclusive if necessary to match the starting date-time.

fun weeksBetween(start: OffsetDateTime, endExclusive: OffsetDateTime): LongWeeks

Get the number of whole weeks between two zoned date-times, adjusting the time zone of endExclusive if necessary to match the starting date-time.

fun weeksBetween(start: ZonedDateTime, endExclusive: ZonedDateTime): LongWeeks
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

yearsBetween

Get the number of whole years between two dates.

fun yearsBetween(start: Date, endExclusive: Date): IntYears

Get the number of whole years between two date-times, assuming they're in the same time zone.

fun yearsBetween(start: DateTime, endExclusive: DateTime): IntYears

Get the number of whole years between two date-times, adjusting the offset of endExclusive if necessary to match the starting date-time.

fun yearsBetween(start: OffsetDateTime, endExclusive: OffsetDateTime): IntYears

Get the number of whole years between two zoned date-times, adjusting the time zone of endExclusive if necessary to match the starting date-time.

fun yearsBetween(start: ZonedDateTime, endExclusive: ZonedDateTime): IntYears