DateTimeUnit

@Serializable(with = DateTimeUnitSerializer::class)
sealed class DateTimeUnit(source)

A unit for measuring time.

See the predefined constants for time units, like DateTimeUnit.NANOSECOND, DateTimeUnit.DAY, DateTimeUnit.MONTH, and others.

Two ways are provided to create custom DateTimeUnit instances:

  • By multiplying an existing unit on the right by an integer scalar: for example, DateTimeUnit.NANOSECOND * 10.

  • By constructing an instance manually with TimeBased, DayBased, or MonthBased: for example, TimeBased(nanoseconds = 10).

Note that a calendar day is not considered identical to 24 hours. See DateTimeUnit.DayBased for a discussion.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard

A date-time unit equal to some number of days or months.

Link copied to clipboard

A date-time unit equal to some number of calendar days.

Link copied to clipboard

A date-time unit equal to some number of months.

Link copied to clipboard
class TimeBased(val nanoseconds: Long) : DateTimeUnit

A date-time unit that has the precise time duration.

Functions

Link copied to clipboard
abstract operator fun times(scalar: Int): DateTimeUnit

Produces a date-time unit that is a multiple of this unit times the specified integer scalar value.