DateRange

An inclusive range of dates.

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

class DateRange(start: Date,endInclusive: Date) : DateDayProgression, Interval<Date> , ClosedRange<Date>

Constructors

DateRange
Link copied to clipboard
common
fun DateRange(start: Date, endInclusive: Date)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

asPeriod
Link copied to clipboard
common

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.

fun asPeriod(): Period
contains
Link copied to clipboard
common

Checks if this interval contains value.

open operator override fun contains(value: Date): Boolean
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hasBoundedEnd
Link copied to clipboard
common

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

open override fun hasBoundedEnd(): Boolean
hasBoundedStart
Link copied to clipboard
common

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

open override fun hasBoundedStart(): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
hasUnboundedEnd
Link copied to clipboard
common

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

open override fun hasUnboundedEnd(): Boolean
hasUnboundedStart
Link copied to clipboard
common

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

open override fun hasUnboundedStart(): Boolean
isBounded
Link copied to clipboard
common

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

open override fun isBounded(): Boolean
isEmpty
Link copied to clipboard
common

Checks if this progression is empty.

open override fun isEmpty(): Boolean
isUnbounded
Link copied to clipboard
common

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

open override fun isUnbounded(): Boolean
iterator
Link copied to clipboard
common
open operator override fun iterator(): Iterator<Date>
toString
Link copied to clipboard
common

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

open override fun toString(): String

Properties

endExclusive
Link copied to clipboard
common

The end of this interval, exclusive.

open override val endExclusive: Date
endInclusive
Link copied to clipboard
common

The end of this interval, inclusive.

open override val endInclusive: Date
first
Link copied to clipboard
common
open override val first: Date
last
Link copied to clipboard
common
open override val last: Date
lengthInDays
Link copied to clipboard
common

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

val lengthInDays: LongDays
lengthInMonths
Link copied to clipboard
common

The number of whole months in this range.

val lengthInMonths: IntMonths
lengthInWeeks
Link copied to clipboard
common

The number of whole weeks in this range.

val lengthInWeeks: LongWeeks
lengthInYears
Link copied to clipboard
common

The number of whole years in this range.

val lengthInYears: IntYears
start
Link copied to clipboard
common

The start of this interval, inclusive.

open override val start: Date
step
Link copied to clipboard
common
open override val step: IntDays

Extensions

at
Link copied to clipboard
common

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
random
Link copied to clipboard
common

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

fun DateRange.random(): Date

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

fun DateRange.random(random: Random): Date
randomOrNull
Link copied to clipboard
common

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

fun DateRange.randomOrNull(): Date?

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

fun DateRange.randomOrNull(random: Random): Date?
toInstantIntervalAt
Link copied to clipboard
common

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