nanoseconds
The number of whole nanoseconds in this period that don't form a whole second, so this value is always in (-999_999_999..999_999_999)
.
Samples
import kotlinx.datetime.*
import kotlin.test.*
import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.minutes
fun main() {
//sampleStart
// Reading the normalized values that make up a DateTimePeriod
val period = DateTimePeriod(
years = -12, months = 122, days = -1440,
hours = 400, minutes = -80, seconds = 123, nanoseconds = -123456789
)
// years and months have the same sign and are normalized together:
check(period.years == -1) // -12 years + (122 months % 12) + 1 year
check(period.months == -10) // (122 months % 12) - 1 year
// days are separate from months and are not normalized:
check(period.days == -1440)
// hours, minutes, seconds, and nanoseconds are normalized together and have the same sign:
check(period.hours == 398) // 400 hours - 2 hours' worth of minutes
check(period.minutes == 42) // -80 minutes + 2 hours' worth of minutes + 120 seconds
check(period.seconds == 2) // 123 seconds - 2 minutes' worth of seconds - 1 second
check(period.nanoseconds == 876543211) // -123456789 nanoseconds + 1 second
//sampleEnd
}