DateRange

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
Link copied to clipboard
common
fun DateRange(start: Date = Date.MIN, endInclusive: Date = Date.MAX)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

asPeriod
Link copied to clipboard
common
fun asPeriod(): Period
Converts this range into a Period of the same length.
contains
Link copied to clipboard
common
open operator override fun contains(value: Date): Boolean
Checks if this interval contains value.
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hasBoundedEnd
Link copied to clipboard
common
open fun hasBoundedEnd(): Boolean
Checks if this interval's end is bounded, meaning it has a finite value.
hasBoundedStart
Link copied to clipboard
common
open fun hasBoundedStart(): Boolean
Checks if this interval's start is bounded, meaning it has a finite value.
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
hasUnboundedEnd
Link copied to clipboard
common
open override fun hasUnboundedEnd(): Boolean
Checks if this interval's end is unbounded.
hasUnboundedStart
Link copied to clipboard
common
open override fun hasUnboundedStart(): Boolean
Checks if this interval's start is unbounded.
isBounded
Link copied to clipboard
common
open fun isBounded(): Boolean
Checks if both the start and end of this interval are bounded, meaning it has a finite range.
isEmpty
Link copied to clipboard
common
open override fun isEmpty(): Boolean
Checks if this progression is empty.
isUnbounded
Link copied to clipboard
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
Link copied to clipboard
common
open operator override fun iterator(): Iterator<Date>
toString
Link copied to clipboard
common
open override fun toString(): String
Converts this range to a string in ISO-8601 extended format.

Properties

endExclusive
Link copied to clipboard
common
open override val endExclusive: Date
The end of this interval, exclusive.
endInclusive
Link copied to clipboard
common
open override val endInclusive: Date
The end of this interval, inclusive.
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
val lengthInDays: LongDays
The number of days in this range.
lengthInMonths
Link copied to clipboard
common
val lengthInMonths: IntMonths
The number of whole months in this range.
lengthInWeeks
Link copied to clipboard
common
val lengthInWeeks: LongWeeks
The number of whole weeks in this range.
lengthInYears
Link copied to clipboard
common
val lengthInYears: IntYears
The number of whole years in this range.
start
Link copied to clipboard
common
open override val start: Date
The start of this interval, inclusive.
step
Link copied to clipboard
common
open override val step: IntDays

Extensions

at
Link copied to clipboard
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.
random
Link copied to clipboard
common
fun DateRange.random(): Date
Returns a random date within this range using the default random number generator.
fun DateRange.random(random: Random): Date
Returns a random date within this range using the supplied random number generator.
randomOrNull
Link copied to clipboard
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.
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
Link copied to clipboard
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.