Month Based
A datetime unit equal to some number of months.
Since different months have a different number of days, a MonthBased
unit cannot be expressed as a multiple of some DayBased-unit.
See also
for a description of datetime units in general.
Samples
import kotlinx.datetime.*
import kotlin.test.*
import kotlin.time.Duration.Companion.hours
fun main() {
//sampleStart
// Constructing various month-based measurement units
val halfYear = DateTimeUnit.MonthBased(months = 6)
check(halfYear.months == 6)
check(halfYear == DateTimeUnit.QUARTER * 2)
check(halfYear == DateTimeUnit.MONTH * 6)
//sampleEnd
}
Functions
Link copied to clipboard
Produces a datetime unit that is a multiple of this unit times the specified integer scalar value.