offset Seconds Of Minute
The second-of-minute of the UTC offset.
By default, it's zero-padded to two digits, but this can be changed with padding.
This field has the default value of 0. If you want to omit it, use optional.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Defining a custom format for the UTC offset
val format = UtcOffset.Format {
// if the offset is zero, `GMT` is printed
optional("GMT") {
offsetHours(); char(':'); offsetMinutesOfHour()
// if seconds are zero, they are omitted
optional { char(':'); offsetSecondsOfMinute() }
}
}
check(format.format(UtcOffset.ZERO) == "GMT")
check(format.format(UtcOffset(hours = -2)) == "-02:00")
check(format.format(UtcOffset(hours = -2, minutes = -30)) == "-02:30")
check(format.format(UtcOffset(hours = -2, minutes = -30, seconds = -59)) == "-02:30:59")
//sampleEnd
}