Month

fun Month(number: Int): Month(source)

Returns the Month instance for the given month number. January is 1, December is 12.

Throws

if the month number is not in the range 1..12

Samples

import kotlinx.datetime.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // Constructing a Month using the constructor function
check(Month(1) == Month.JANUARY)
check(Month(2) == Month.FEBRUARY)
// ...
check(Month(12) == Month.DECEMBER)
try {
    Month(0)
    fail("Expected IllegalArgumentException")
} catch (e: IllegalArgumentException) {
    // Expected
} 
   //sampleEnd
}