Day Based
A date-time unit equal to some number of calendar days.
A calendar day is not considered identical to 24 hours. Thus, a DayBased
unit cannot be expressed as a multiple of some TimeBased unit.
The reason lies in time zone transitions, because of which some days can be 23 or 25 hours. For example, we say that exactly a whole day has passed between 2019-10-27T02:59
and 2019-10-28T02:59
in Berlin, despite the fact that the clocks were turned back one hour, so there are, in fact, 25 hours between the two date-times.
See also
for a description of date-time units in general.
Samples
import kotlinx.datetime.*
import kotlin.test.*
import kotlin.time.Duration.Companion.hours
fun main() {
//sampleStart
// Constructing various day-based measurement units
val iteration = DateTimeUnit.DayBased(days = 14)
check(iteration.days == 14)
check(iteration == DateTimeUnit.DAY * 14)
check(iteration == DateTimeUnit.WEEK * 2)
//sampleEnd
}
Functions
Link copied to clipboard
Produces a date-time unit that is a multiple of this unit times the specified integer scalar value.