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)

DateDayProgression

open class DateDayProgression : Iterable<Date>
(iosArm64, iosX64, jvm, macosX64)

DateIterator

abstract class DateIterator : Iterator<Date>
(iosArm64, iosX64, jvm, macosX64)

DateMonthProgression

class DateMonthProgression : Iterable<Date>
(iosArm64, iosX64, jvm, macosX64)

DateRange

An inclusive range of dates.

class DateRange : DateDayProgression, ClosedRange<Date>
(iosArm64, iosX64, jvm, macosX64)

DateTimeInterval

An interval between two arbitrary date-times.

class DateTimeInterval : TimeInterval<DateTime>
(iosArm64, iosX64, jvm, macosX64)

InstantInterval

A half-open interval between two instants.

class InstantInterval : TimePointInterval<Instant>, TimePointProgressionBuilder<Instant>
(iosArm64, iosX64, jvm, macosX64)

OffsetDateTimeInterval

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

class OffsetDateTimeInterval : TimePointInterval<OffsetDateTime>
(iosArm64, iosX64, jvm, macosX64)

TimeInterval

A half-open time interval.

interface TimeInterval<T>
(iosArm64, iosX64, jvm, macosX64)

TimePointInterval

A half-open interval of time points.

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

TimePointIterator

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

TimePointNanosecondProgression

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

TimePointProgressionBuilder

A time point progression builder.

interface TimePointProgressionBuilder<T : TimePoint<T>>
(iosArm64, iosX64, jvm, macosX64)

TimePointSecondProgression

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

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)

kotlin.String

Functions

(iosArm64, iosX64, jvm, macosX64)

asInstantInterval

Convert an OffsetDateTimeInterval into an InstantInterval.

fun OffsetDateTimeInterval.asInstantInterval(): InstantInterval

Convert a ZonedDateTimeInterval until an InstantInterval.

fun ZonedDateTimeInterval.asInstantInterval(): InstantInterval
(iosArm64, iosX64, jvm, macosX64)

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 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)

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)

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)

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)

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)

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)

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)

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, ignoring the offsets.

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)

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)

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, ignoring the offsets.

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) 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
(jvm) fun ZonedDateTimeInterval.random(random: Random): ZonedDateTime
(iosArm64, iosX64, macosX64) fun DateTimeInterval.random(random: <ERROR CLASS>): DateTime
(iosArm64, iosX64, macosX64) fun ZonedDateTimeInterval.random(random: <ERROR CLASS>): ZonedDateTime

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

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

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

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

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

(iosArm64, iosX64, jvm, macosX64) fun DateRange.random(): Date

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

(iosArm64, iosX64, jvm, macosX64) fun DateTimeInterval.random(): DateTime
(iosArm64, iosX64, jvm, macosX64) fun ZonedDateTimeInterval.random(): ZonedDateTime

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

(iosArm64, iosX64, jvm, macosX64) fun InstantInterval.random(): Instant

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

(iosArm64, iosX64, jvm, macosX64) fun OffsetDateTimeInterval.random(): OffsetDateTime
(iosArm64, iosX64, jvm, macosX64)

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)

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)

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)

toInstantIntervalAt

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

fun DateRange.toInstantIntervalAt(zone: TimeZone): InstantInterval
(iosArm64, iosX64, jvm, macosX64)

toZonedDateTimeIntervalAt

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

fun DateRange.toZonedDateTimeIntervalAt(zone: TimeZone): ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64)

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)

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, ignoring the offsets.

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)

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, ignoring the offsets.

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