downTo

Creates a LocalDateProgression from this down to that, inclusive.

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
}

Creates a YearMonthProgression from this down to that, inclusive.

Samples

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

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