MonthBased

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
}

Constructors

Link copied to clipboard
constructor(months: Int)

Properties

Link copied to clipboard
val months: Int

The length of this unit in months.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open operator override fun times(scalar: Int): DateTimeUnit.MonthBased

Produces a datetime unit that is a multiple of this unit times the specified integer scalar value.

Link copied to clipboard
open override fun toString(): String