days

Returns the range of days in the year-month.

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlinx.datetime.onDay
import kotlin.test.*

fun main() { 
   //sampleStart 
   // Getting the range of days in a YearMonth
val yearMonth = YearMonth(2024, Month.APRIL)
// The range consists of all the days in the month:
check(yearMonth.days.size == 30)
check(yearMonth.days.first() == LocalDate(2024, Month.APRIL, 1))
check(yearMonth.days.last() == LocalDate(2024, Month.APRIL, 30))
check(yearMonth.days.contains(LocalDate(2024, Month.APRIL, 15)))
// The range allows iterating over the days:
for (day in yearMonth.days) {
    check(day.month == Month.APRIL)
    check(day.year == 2024)
} 
   //sampleEnd
}