Skip to content

//core/io.islandtime.ranges/DateRange

DateRange

common

class DateRange(start: Date, endInclusive: Date) : DateDayProgression, Interval<Date> , 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

DateRange

common

fun DateRange(start: Date = Date.MIN, endInclusive: Date = Date.MAX)

Types

Name Summary
Companion

common


object Companion

Functions

Name Summary
contains

common


open operator override fun contains(value: Date): Boolean

Checks if this interval contains value.
equals

common


open operator override fun equals(other: Any?): Boolean
hasBoundedEnd

common


open fun hasBoundedEnd(): Boolean

Checks if this interval's end is bounded, meaning it has a finite value.
hasBoundedStart

common


open fun hasBoundedStart(): Boolean

Checks if this interval's start is bounded, meaning it has a finite value.
hashCode

common


open override fun hashCode(): Int
hasUnboundedEnd

common


open override fun hasUnboundedEnd(): Boolean

Checks if this interval's end is unbounded. In ISO-8601 terminology, this is an "open" end.
hasUnboundedStart

common


open override fun hasUnboundedStart(): Boolean

Checks if this interval's start is unbounded. In ISO-8601 terminology, this is an "open" start.
isBounded

common


open fun isBounded(): Boolean

Checks if both the start and end of this interval are bounded, meaning it has a finite range.
isEmpty

common


open override fun isEmpty(): Boolean

Checks if this progression is empty.
isUnbounded

common


open fun isUnbounded(): Boolean

Checks if both the start and end of this interval are unbounded, meaning this is an infinite time period in both directions.
iterator

common


open operator override fun iterator(): Iterator<Date>
toString

common


open override fun toString(): String

Converts this range to a string in ISO-8601 extended format.

Properties

Name Summary
endExclusive

common

open override val endExclusive: Date

The end of this interval, exclusive.
endInclusive

common

open override val endInclusive: Date

The end of this interval, inclusive.
first

common

open override val first: Date
last

common

open override val last: Date
start

common

open override val start: Date

The start of this interval, inclusive.
step

common

open override val step: Days

Extensions

Name Summary
at

common


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

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.
lengthInCenturies

common


val DateRange.lengthInCenturies: Centuries

The number of whole centuries between the start and end of this range.
lengthInDays

common


val DateRange.lengthInDays: Days

The number of days between the start and end of this range. A range is inclusive, so if the start and end date are the same, the length will be one day.
lengthInDecades

common


val DateRange.lengthInDecades: Decades

The number of whole decades between the start and end of this range.
lengthInMonths

common


val DateRange.lengthInMonths: Months

The number of whole months between the start and end of this range.
lengthInWeeks

common


val DateRange.lengthInWeeks: Weeks

The number of whole weeks between the start and end of this range.
lengthInYears

common


val DateRange.lengthInYears: Years

The number of whole years between the start and end of this range.
random

common


fun DateRange.random(): Date

Returns a random date within this range using the default random number generator.

common


fun DateRange.random(random: Random): Date

Returns a random date within this range using the supplied random number generator.
randomOrNull

common


fun DateRange.randomOrNull(): Date?

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

common


fun DateRange.randomOrNull(random: Random): Date?

Returns a random date within this range using the supplied random number generator or null if the interval is empty or unbounded.
toInstantIntervalAt

common


fun DateRange.toInstantIntervalAt(zone: TimeZone): InstantInterval

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

common


fun DateRange.toPeriod(): Period

Converts this range into a Period of the same length. As a range is inclusive, if the start and end date are the same, the resulting period will contain one day.