Package io.islandtime.measures

Classes related to the measurement of time, including Duration, Period, and more specific units, such as IntHours or LongYears.

Types

Duration
Link copied to clipboard
common

A duration of time at nanosecond precision.

For many applications, working with specific units like IntHours or LongSeconds is more efficient and plenty adequate. However, when working with larger durations at sub-second precision, overflow is a very real possibility. Duration is capable of representing fixed, nanosecond-precision durations that span the entire supported time scale, making it more suitable for these use cases.

class Duration : Comparable<Duration>
IntCenturies
Link copied to clipboard
common

A number of centuries.

inline class IntCenturies(value: Int) : Comparable<IntCenturies>
IntDays
Link copied to clipboard
common

A number of days.

inline class IntDays(value: Int) : Comparable<IntDays>
IntDecades
Link copied to clipboard
common

A number of decades.

inline class IntDecades(value: Int) : Comparable<IntDecades>
IntHours
Link copied to clipboard
common

A number of hours.

inline class IntHours(value: Int) : Comparable<IntHours>
IntMicroseconds
Link copied to clipboard
common

A number of microseconds.

inline class IntMicroseconds(value: Int) : Comparable<IntMicroseconds>
IntMilliseconds
Link copied to clipboard
common

A number of milliseconds.

inline class IntMilliseconds(value: Int) : Comparable<IntMilliseconds>
IntMinutes
Link copied to clipboard
common

A number of minutes.

inline class IntMinutes(value: Int) : Comparable<IntMinutes>
IntMonths
Link copied to clipboard
common

A number of months.

inline class IntMonths(value: Int) : Comparable<IntMonths>
IntNanoseconds
Link copied to clipboard
common

A number of nanoseconds.

inline class IntNanoseconds(value: Int) : Comparable<IntNanoseconds>
IntSeconds
Link copied to clipboard
common

A number of seconds.

inline class IntSeconds(value: Int) : Comparable<IntSeconds>
IntWeeks
Link copied to clipboard
common

A number of weeks.

inline class IntWeeks(value: Int) : Comparable<IntWeeks>
IntYears
Link copied to clipboard
common

A number of years.

inline class IntYears(value: Int) : Comparable<IntYears>
LongCenturies
Link copied to clipboard
common

A number of centuries.

inline class LongCenturies(value: Long) : Comparable<LongCenturies>
LongDays
Link copied to clipboard
common

A number of days.

inline class LongDays(value: Long) : Comparable<LongDays>
LongDecades
Link copied to clipboard
common

A number of decades.

inline class LongDecades(value: Long) : Comparable<LongDecades>
LongHours
Link copied to clipboard
common

A number of hours.

inline class LongHours(value: Long) : Comparable<LongHours>
LongMicroseconds
Link copied to clipboard
common

A number of microseconds.

inline class LongMicroseconds(value: Long) : Comparable<LongMicroseconds>
LongMilliseconds
Link copied to clipboard
common

A number of milliseconds.

inline class LongMilliseconds(value: Long) : Comparable<LongMilliseconds>
LongMinutes
Link copied to clipboard
common

A number of minutes.

inline class LongMinutes(value: Long) : Comparable<LongMinutes>
LongMonths
Link copied to clipboard
common

A number of months.

inline class LongMonths(value: Long) : Comparable<LongMonths>
LongNanoseconds
Link copied to clipboard
common

A number of nanoseconds.

inline class LongNanoseconds(value: Long) : Comparable<LongNanoseconds>
LongSeconds
Link copied to clipboard
common

A number of seconds.

inline class LongSeconds(value: Long) : Comparable<LongSeconds>
LongWeeks
Link copied to clipboard
common

A number of weeks.

inline class LongWeeks(value: Long) : Comparable<LongWeeks>
LongYears
Link copied to clipboard
common

A number of years.

inline class LongYears(value: Long) : Comparable<LongYears>
Period
Link copied to clipboard
common

A date-based period of time, such as "2 years, 5 months, 16 days". Unlike Duration, which uses exact increments, a Period works with conceptual days, months, and years, ignoring daylight savings and length differences.

class Period
TimeUnit
Link copied to clipboard
common

A unit of time measurement.

enum TimeUnit : Enum<TimeUnit>

Functions

abs
Link copied to clipboard
common

Returns the absolute value of duration.

fun abs(duration: Duration): Duration
asDuration
Link copied to clipboard
common
fun LongDays.asDuration(): Duration
fun LongHours.asDuration(): Duration
fun LongMinutes.asDuration(): Duration
fun LongSeconds.asDuration(): Duration
fun LongMilliseconds.asDuration(): Duration
fun LongMicroseconds.asDuration(): Duration
fun LongNanoseconds.asDuration(): Duration
fun IntDays.asDuration(): Duration
fun IntHours.asDuration(): Duration
fun IntMinutes.asDuration(): Duration
fun IntSeconds.asDuration(): Duration
fun IntMilliseconds.asDuration(): Duration
fun IntMicroseconds.asDuration(): Duration
fun IntNanoseconds.asDuration(): Duration
asPeriod
Link copied to clipboard
common

Converts this duration into a Period with the same number of years.

fun IntYears.asPeriod(): Period
fun LongYears.asPeriod(): Period

Converts this duration into a Period with the same number of months.

fun IntMonths.asPeriod(): Period
fun LongMonths.asPeriod(): Period

Converts this duration into a Period with the same number of weeks.

fun IntWeeks.asPeriod(): Period
fun LongWeeks.asPeriod(): Period

Converts this duration into a Period with the same number of days.

fun IntDays.asPeriod(): Period
fun LongDays.asPeriod(): Period
durationOf
Link copied to clipboard
common

Creates a Duration.

fun durationOf(seconds: IntSeconds, nanoseconds: IntNanoseconds): Duration
fun durationOf(seconds: LongSeconds, nanoseconds: IntNanoseconds): Duration
fun durationOf(seconds: IntSeconds, nanoseconds: LongNanoseconds): Duration
fun durationOf(seconds: LongSeconds, nanoseconds: LongNanoseconds): Duration

Creates a Duration of 24-hour days.

fun durationOf(days: IntDays): Duration
fun durationOf(days: LongDays): Duration

Creates a Duration of hours.

fun durationOf(hours: IntHours): Duration
fun durationOf(hours: LongHours): Duration

Creates a Duration of minutes.

fun durationOf(minutes: IntMinutes): Duration
fun durationOf(minutes: LongMinutes): Duration

Creates a Duration of seconds.

fun durationOf(seconds: IntSeconds): Duration
fun durationOf(seconds: LongSeconds): Duration

Creates a Duration of milliseconds.

fun durationOf(milliseconds: IntMilliseconds): Duration
fun durationOf(milliseconds: LongMilliseconds): Duration

Creates a Duration of microseconds.

fun durationOf(microseconds: IntMicroseconds): Duration
fun durationOf(microseconds: LongMicroseconds): Duration

Creates a Duration of nanoseconds.

fun durationOf(nanoseconds: IntNanoseconds): Duration
fun durationOf(nanoseconds: LongNanoseconds): Duration
minus
Link copied to clipboard
common
operator fun IntYears.minus(period: Period): Period
operator fun IntMonths.minus(period: Period): Period
operator fun IntWeeks.minus(period: Period): Period
operator fun IntDays.minus(period: Period): Period
operator fun LongYears.minus(period: Period): Period
operator fun LongMonths.minus(period: Period): Period
operator fun LongWeeks.minus(period: Period): Period
operator fun LongDays.minus(period: Period): Period
periodOf
Link copied to clipboard
common

Creates a Period.

fun periodOf(years: IntYears, months: IntMonths, days: IntDays): Period
fun periodOf(years: IntYears, days: IntDays): Period
fun periodOf(months: IntMonths, days: IntDays): Period
fun periodOf(weeks: IntWeeks): Period
fun periodOf(days: IntDays): Period
plus
Link copied to clipboard
common
operator fun IntYears.plus(period: Period): Period
operator fun IntMonths.plus(period: Period): Period
operator fun IntWeeks.plus(period: Period): Period
operator fun IntDays.plus(period: Period): Period
operator fun LongYears.plus(period: Period): Period
operator fun LongMonths.plus(period: Period): Period
operator fun LongWeeks.plus(period: Period): Period
operator fun LongDays.plus(period: Period): Period
times
Link copied to clipboard
common

Multiplies this value by a duration of centuries.

operator fun Int.times(centuries: IntCenturies): IntCenturies
operator fun Long.times(centuries: IntCenturies): LongCenturies
operator fun Int.times(centuries: LongCenturies): LongCenturies
operator fun Long.times(centuries: LongCenturies): LongCenturies

Multiplies this value by a duration of days.

operator fun Int.times(days: IntDays): IntDays
operator fun Long.times(days: IntDays): LongDays
operator fun Int.times(days: LongDays): LongDays
operator fun Long.times(days: LongDays): LongDays

Multiplies this value by a duration of decades.

operator fun Int.times(decades: IntDecades): IntDecades
operator fun Long.times(decades: IntDecades): LongDecades
operator fun Int.times(decades: LongDecades): LongDecades
operator fun Long.times(decades: LongDecades): LongDecades

Multiplies this value by a duration of hours.

operator fun Int.times(hours: IntHours): IntHours
operator fun Long.times(hours: IntHours): LongHours
operator fun Int.times(hours: LongHours): LongHours
operator fun Long.times(hours: LongHours): LongHours

Multiplies this value by a duration of microseconds.

operator fun Int.times(microseconds: IntMicroseconds): LongMicroseconds
operator fun Long.times(microseconds: IntMicroseconds): LongMicroseconds
operator fun Int.times(microseconds: LongMicroseconds): LongMicroseconds
operator fun Long.times(microseconds: LongMicroseconds): LongMicroseconds

Multiplies this value by a duration of milliseconds.

operator fun Int.times(milliseconds: IntMilliseconds): LongMilliseconds
operator fun Long.times(milliseconds: IntMilliseconds): LongMilliseconds
operator fun Int.times(milliseconds: LongMilliseconds): LongMilliseconds
operator fun Long.times(milliseconds: LongMilliseconds): LongMilliseconds

Multiplies this value by a duration of minutes.

operator fun Int.times(minutes: IntMinutes): IntMinutes
operator fun Long.times(minutes: IntMinutes): LongMinutes
operator fun Int.times(minutes: LongMinutes): LongMinutes
operator fun Long.times(minutes: LongMinutes): LongMinutes

Multiplies this value by a duration of months.

operator fun Int.times(months: IntMonths): IntMonths
operator fun Long.times(months: IntMonths): LongMonths
operator fun Int.times(months: LongMonths): LongMonths
operator fun Long.times(months: LongMonths): LongMonths

Multiplies this value by a duration of nanoseconds.

operator fun Int.times(nanoseconds: IntNanoseconds): LongNanoseconds
operator fun Long.times(nanoseconds: IntNanoseconds): LongNanoseconds
operator fun Int.times(nanoseconds: LongNanoseconds): LongNanoseconds
operator fun Long.times(nanoseconds: LongNanoseconds): LongNanoseconds

Multiplies this value by a duration of seconds.

operator fun Int.times(seconds: IntSeconds): IntSeconds
operator fun Long.times(seconds: IntSeconds): LongSeconds
operator fun Int.times(seconds: LongSeconds): LongSeconds
operator fun Long.times(seconds: LongSeconds): LongSeconds

Multiplies this value by a duration of weeks.

operator fun Int.times(weeks: IntWeeks): IntWeeks
operator fun Long.times(weeks: IntWeeks): LongWeeks
operator fun Int.times(weeks: LongWeeks): LongWeeks
operator fun Long.times(weeks: LongWeeks): LongWeeks

Multiplies this value by a duration of years.

operator fun Int.times(years: IntYears): IntYears
operator fun Long.times(years: IntYears): LongYears
operator fun Int.times(years: LongYears): LongYears
operator fun Long.times(years: LongYears): LongYears

Multiplies this value by a duration.

operator fun Int.times(duration: Duration): Duration
operator fun Int.times(period: Period): Period
toDuration
Link copied to clipboard
common

Converts an ISO-8601 duration string to a Duration.

fun String.toDuration(): Duration

Converts a string to a Duration using parser.

fun String.toDuration(parser: DateTimeParser, settings: DateTimeParserSettings): Duration
toIslandDays
Link copied to clipboard
common

Converts this duration to Island Time LongDays.

fun Duration.toIslandDays(): LongDays
toIslandDuration
Link copied to clipboard
common

Converts this duration to an equivalent Island Time Duration.

fun Duration.toIslandDuration(): Duration
toIslandHours
Link copied to clipboard
common

Converts this duration to Island Time LongHours.

fun Duration.toIslandHours(): LongHours
toIslandMicroseconds
Link copied to clipboard
common

Converts this duration to Island Time LongMicroseconds.

fun Duration.toIslandMicroseconds(): LongMicroseconds
toIslandMilliseconds
Link copied to clipboard
common

Converts this duration to Island Time LongMilliseconds.

fun Duration.toIslandMilliseconds(): LongMilliseconds
toIslandMinutes
Link copied to clipboard
common

Converts this duration to Island Time LongMinutes.

fun Duration.toIslandMinutes(): LongMinutes
toIslandNanoseconds
Link copied to clipboard
common

Converts this duration to Island Time LongNanoseconds.

fun Duration.toIslandNanoseconds(): LongNanoseconds
toIslandSeconds
Link copied to clipboard
common

Converts this duration to Island Time LongSeconds.

fun Duration.toIslandSeconds(): LongSeconds
toPeriod
Link copied to clipboard
common
fun String.toPeriod(): Period
fun String.toPeriod(parser: DateTimeParser, settings: DateTimeParserSettings): Period

Properties

centuries
Link copied to clipboard
common

Converts this value to a duration of centuries.

val Int.centuries: IntCenturies
centuries
Link copied to clipboard
common

Converts this value to a duration of centuries.

val Long.centuries: LongCenturies
days
Link copied to clipboard
common

Converts this value to a duration of days.

val Int.days: IntDays
days
Link copied to clipboard
common

Converts this value to a duration of days.

val Long.days: LongDays
decades
Link copied to clipboard
common

Converts this value to a duration of decades.

val Int.decades: IntDecades
decades
Link copied to clipboard
common

Converts this value to a duration of decades.

val Long.decades: LongDecades
hours
Link copied to clipboard
common

Converts this value to a duration of hours.

val Int.hours: IntHours
hours
Link copied to clipboard
common

Converts this value to a duration of hours.

val Long.hours: LongHours
microseconds
Link copied to clipboard
common

Converts this value to a duration of microseconds.

val Int.microseconds: IntMicroseconds
microseconds
Link copied to clipboard
common

Converts this value to a duration of microseconds.

val Long.microseconds: LongMicroseconds
milliseconds
Link copied to clipboard
common

Converts this value to a duration of milliseconds.

val Int.milliseconds: IntMilliseconds
milliseconds
Link copied to clipboard
common

Converts this value to a duration of milliseconds.

val Long.milliseconds: LongMilliseconds
minutes
Link copied to clipboard
common

Converts this value to a duration of minutes.

val Int.minutes: IntMinutes
minutes
Link copied to clipboard
common

Converts this value to a duration of minutes.

val Long.minutes: LongMinutes
months
Link copied to clipboard
common

Converts this value to a duration of months.

val Int.months: IntMonths
months
Link copied to clipboard
common

Converts this value to a duration of months.

val Long.months: LongMonths
nanoseconds
Link copied to clipboard
common

Converts this value to a duration of nanoseconds.

val Int.nanoseconds: IntNanoseconds
nanoseconds
Link copied to clipboard
common

Converts this value to a duration of nanoseconds.

val Long.nanoseconds: LongNanoseconds
seconds
Link copied to clipboard
common

Converts this value to a duration of seconds.

val Int.seconds: IntSeconds
seconds
Link copied to clipboard
common

Converts this value to a duration of seconds.

val Long.seconds: LongSeconds
weeks
Link copied to clipboard
common

Converts this value to a duration of weeks.

val Int.weeks: IntWeeks
weeks
Link copied to clipboard
common

Converts this value to a duration of weeks.

val Long.weeks: LongWeeks
years
Link copied to clipboard
common

Converts this value to a duration of years.

val Int.years: IntYears
years
Link copied to clipboard
common

Converts this value to a duration of years.

val Long.years: LongYears