LocalDateRange

A range of values of type LocalDate.

Samples

import kotlinx.datetime.*
import kotlin.random.Random
import kotlin.test.Test

fun main() { 
   //sampleStart 
   // Creating LocalDateRange from LocalDate
check((LocalDate(2000, 1, 1)..LocalDate(2000, 1, 5)).toList() == listOf(
    LocalDate(2000, 1, 1),
    LocalDate(2000, 1, 2),
    LocalDate(2000, 1, 3),
    LocalDate(2000, 1, 4),
    LocalDate(2000, 1, 5)
))
check(
    (LocalDate(2000, 1, 1)..<LocalDate(2000, 1, 6)).toList() == listOf(
        LocalDate(2000, 1, 1),
        LocalDate(2000, 1, 2),
        LocalDate(2000, 1, 3),
        LocalDate(2000, 1, 4),
        LocalDate(2000, 1, 5)
    ))
check(
    (LocalDate(2000, 1, 5) downTo LocalDate(2000, 1, 1)).toList() == listOf(
        LocalDate(2000, 1, 5),
        LocalDate(2000, 1, 4),
        LocalDate(2000, 1, 3),
        LocalDate(2000, 1, 2),
        LocalDate(2000, 1, 1)
    )) 
   //sampleEnd
}

Constructors

Link copied to clipboard
constructor(start: LocalDate, endInclusive: LocalDate)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val endInclusive: LocalDate

Returns the upper bound of the range, inclusive.

Link copied to clipboard
open override val start: LocalDate

Returns the lower bound of the range, inclusive.

Functions

Link copied to clipboard
open operator override fun contains(value: LocalDate): Boolean

Returns true iff value is contained within the range. i.e. value is between start and endInclusive.

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

Returns true iff there are no dates contained within the range.

Link copied to clipboard
open override fun toString(): String

Returns a string representation of the range using the range operator notation.