toUtcOffset

Builds a UtcOffset from the fields in this DateTimeComponents.

This method uses the following fields:

Throws

if any of the fields has an out-of-range value.

Samples

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

fun main() { 
   //sampleStart 
   // Obtaining a UTC offset from the parsed data
val rfc1123Input = "Sun, 06 Nov 1994 08:49:37 +0300"
val parsed = DateTimeComponents.Formats.RFC_1123.parse(rfc1123Input)
val offset = parsed.toUtcOffset()
check(offset == UtcOffset(3, 0)) 
   //sampleEnd
}