DayOfWeek

fun DayOfWeek(isoDayNumber: Int): DayOfWeek(source)

Returns the DayOfWeek instance for the given ISO 8601 week day number. Monday is 1, Sunday is 7.

Throws

if the day number is not in the range 1..7

Samples

import kotlinx.datetime.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   // Constructing a DayOfWeek from the ISO day-of-week number
check(DayOfWeek(isoDayNumber = 1) == DayOfWeek.MONDAY)
check(DayOfWeek(isoDayNumber = 2) == DayOfWeek.TUESDAY)
// ...
check(DayOfWeek(isoDayNumber = 7) == DayOfWeek.SUNDAY)
try {
    DayOfWeek(0)
    fail("Expected IllegalArgumentException")
} catch (e: IllegalArgumentException) {
    // Expected
} 
   //sampleEnd
}