to Year Month
Builds a YearMonth from the fields in this DateTimeComponents.
This method uses the following fields:
Throws
if any of the fields is missing or invalid.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
import kotlin.time.Instant
fun main() {
//sampleStart
// Obtaining a YearMonth from the parsed data
val rfc1123Input = "Sun, 06 Nov 1994 08:49:37 +0300"
val parsed = DateTimeComponents.Formats.RFC_1123.parse(rfc1123Input)
val yearMonth = parsed.toYearMonth()
check(yearMonth == YearMonth(1994, Month.NOVEMBER))
//sampleEnd
}