DateTimePeriod

sealed class DateTimePeriod

A difference between two instants, decomposed into date and time components.

The date components are: years, months, days.

The time components are: hours, minutes, seconds, nanoseconds.

A DateTimePeriod can be constructed using the same-named constructor function, parsed from a string, or returned as the result of instant arithmetic operations (see Instant.periodUntil). All these functions can return a DatePeriod value, which is a subtype of DateTimePeriod, a special case that only stores date components, if all time components of the result happen to be zero.

Types

Link copied to clipboard
object Companion

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 override fun toString(): String

Converts this period to the ISO-8601 string representation for durations.

Properties

Link copied to clipboard
abstract val days: Int

The number of calendar days.

Link copied to clipboard
open val hours: Int

The number of whole hours in this period.

Link copied to clipboard
open val minutes: Int

The number of whole minutes in this period that don't form a whole hour, so this value is always in (-59..59).

Link copied to clipboard
val months: Int

The number of months in this period that don't form a whole year, so this value is always in (-11..11).

Link copied to clipboard
open val nanoseconds: Int

The number of whole nanoseconds in this period that don't form a whole second, so this value is always in (-999_999_999..999_999_999).

Link copied to clipboard
open val seconds: Int

The number of whole seconds in this period that don't form a whole minute, so this value is always in (-59..59).

Link copied to clipboard
val years: Int

The number of whole years.

Inheritors

Link copied to clipboard

Extensions

Link copied to clipboard
operator fun DateTimePeriod.plus(other: DateTimePeriod): DateTimePeriod

Adds two DateTimePeriod instances.