core / io.islandtime.ranges / DateRange

DateRange

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

An inclusive range of dates.

Date.MIN and Date.MAX are used as sentinels to indicate an unbounded (ie. infinite) start or end.

Constructors

(iosArm64, iosX64, jvm, macosX64)

<init>

An inclusive range of dates.

<init>(start: Date = Date.MIN, endInclusive: Date = Date.MAX)

Properties

(iosArm64, iosX64, jvm, macosX64)

endInclusive

val endInclusive: Date
(iosArm64, iosX64, jvm, macosX64)

lengthInDays

Get the number of days in the range. As a range is inclusive, if the start and end date are the same, the result will be one day.

val lengthInDays: LongDays
(iosArm64, iosX64, jvm, macosX64)

lengthInMonths

Get the number of months in the range. A month is considered to have passed if the day of the end month is greater than or equal to the day of the start month minus one (as a range is inclusive).

val lengthInMonths: IntMonths
(iosArm64, iosX64, jvm, macosX64)

lengthInWeeks

Get the number of weeks in the range.

val lengthInWeeks: LongWeeks
(iosArm64, iosX64, jvm, macosX64)

lengthInYears

Get the number of years in the range. A year is considered to have passed if twelve full months have passed between the start date and end date, according to the definition of 'month' in lengthInMonths.

val lengthInYears: IntYears
(iosArm64, iosX64, jvm, macosX64)

start

val start: Date

Functions

(iosArm64, iosX64, jvm, macosX64)

asPeriod

Convert a range of dates into a period containing each day in the range. As a range is inclusive, if the start and end date are the same, the resulting period will contain one day.

fun asPeriod(): Period
(iosArm64, iosX64, jvm, macosX64)

equals

fun equals(other: Any?): Boolean
(iosArm64, iosX64, jvm, macosX64)

hasBoundedEnd

fun hasBoundedEnd(): Boolean
(iosArm64, iosX64, jvm, macosX64)

hasBoundedStart

fun hasBoundedStart(): Boolean
(iosArm64, iosX64, jvm, macosX64)

hashCode

fun hashCode(): Int
(iosArm64, iosX64, jvm, macosX64)

hasUnboundedEnd

fun hasUnboundedEnd(): Boolean
(iosArm64, iosX64, jvm, macosX64)

hasUnboundedStart

fun hasUnboundedStart(): Boolean
(iosArm64, iosX64, jvm, macosX64)

isBounded

fun isBounded(): Boolean
(iosArm64, iosX64, jvm, macosX64)

isEmpty

Is the progression empty?

fun isEmpty(): Boolean
(iosArm64, iosX64, jvm, macosX64)

isUnbounded

fun isUnbounded(): Boolean
(iosArm64, iosX64, jvm, macosX64)

toString

Convert this interval to a string in ISO-8601 extended format.

fun toString(): String

Companion Object Properties

(iosArm64, iosX64, jvm, macosX64)

EMPTY

A range containing zero days.

val EMPTY: DateRange
(iosArm64, iosX64, jvm, macosX64)

UNBOUNDED

An unbounded (ie. infinite) range of dates.

val UNBOUNDED: DateRange

Extension Functions

(jvm)

random

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

fun DateRange.random(random: Random): Date