days

open override val days: Int(source)

The number of calendar days. Can be negative.

Note that a calendar day is not identical to 24 hours, see DateTimeUnit.DayBased for details. Also, this field does not get normalized together with months, so values larger than 31 can be present.

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
}