Skip to content

//core/io.islandtime.measures

Package-level declarations

common

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

Types

Name Summary
Centuries

common


@JvmInline

value class Centuries(val value: Long) : Comparable<Centuries>
Days

common


@JvmInline

value class Days(val value: Long) : Comparable<Days>
Decades

common


@JvmInline

value class Decades(val value: Long) : Comparable<Decades>
Duration

common


@Serializable(with = DurationIsoSerializer::class)

class Duration : Comparable<Duration>


A duration of time at nanosecond precision.
Hours

common


@JvmInline

value class Hours(val value: Long) : Comparable<Hours>
Microseconds

common


@JvmInline

value class Microseconds(val value: Long) : Comparable<Microseconds>
Milliseconds

common


@JvmInline

value class Milliseconds(val value: Long) : Comparable<Milliseconds>
Minutes

common


@JvmInline

value class Minutes(val value: Long) : Comparable<Minutes>
Months

common


@JvmInline

value class Months(val value: Long) : Comparable<Months>
Nanoseconds

common


@JvmInline

value class Nanoseconds(val value: Long) : Comparable<Nanoseconds>
Period

common


@Serializable(with = PeriodIsoSerializer::class)

class Period


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.
Seconds

common


@JvmInline

value class Seconds(val value: Long) : Comparable<Seconds>
TimeUnit

common


enum TimeUnit : Enum<TimeUnit>

A unit of time measurement.
Weeks

common


@JvmInline

value class Weeks(val value: Long) : Comparable<Weeks>
Years

common


@JvmInline

value class Years(val value: Long) : Comparable<Years>

Properties

Name Summary
centuries

common


val Int.centuries: Centuries

val Long.centuries: Centuries

Converts this value to a duration of centuries.
days

common


val Int.days: Days

val Long.days: Days

Converts this value to a duration of days.
decades

common


val Int.decades: Decades

val Long.decades: Decades

Converts this value to a duration of decades.
hours

common


val Int.hours: Hours

val Long.hours: Hours

Converts this value to a duration of hours.
microseconds

common


val Int.microseconds: Microseconds

val Long.microseconds: Microseconds

Converts this value to a duration of microseconds.
milliseconds

common


val Int.milliseconds: Milliseconds

val Long.milliseconds: Milliseconds

Converts this value to a duration of milliseconds.
minutes

common


val Int.minutes: Minutes

val Long.minutes: Minutes

Converts this value to a duration of minutes.
months

common


val Int.months: Months

val Long.months: Months

Converts this value to a duration of months.
nanoseconds

common


val Int.nanoseconds: Nanoseconds

val Long.nanoseconds: Nanoseconds

Converts this value to a duration of nanoseconds.
seconds

common


val Int.seconds: Seconds

val Long.seconds: Seconds

Converts this value to a duration of seconds.
weeks

common


val Int.weeks: Weeks

val Long.weeks: Weeks

Converts this value to a duration of weeks.
years

common


val Int.years: Years

val Long.years: Years

Converts this value to a duration of years.

Functions

Name Summary
abs

common


fun abs(duration: Duration): Duration

Returns the absolute value of a duration.
asDuration

common


fun Days.asDuration(): Duration

fun Hours.asDuration(): Duration

fun Microseconds.asDuration(): Duration

fun Milliseconds.asDuration(): Duration

fun Minutes.asDuration(): Duration

fun Nanoseconds.asDuration(): Duration

fun Seconds.asDuration(): Duration
asPeriod

common


fun Days.asPeriod(): Period

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

common


fun Months.asPeriod(): Period

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

common


fun Weeks.asPeriod(): Period

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

common


fun Years.asPeriod(): Period

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

common


fun durationOf(days: Days): Duration

Creates a Duration of 24-hour days.

common


fun durationOf(hours: Hours): Duration

Creates a Duration of hours.

common


fun durationOf(microseconds: Microseconds): Duration

Creates a Duration of microseconds.

common


fun durationOf(milliseconds: Milliseconds): Duration

Creates a Duration of milliseconds.

common


fun durationOf(minutes: Minutes): Duration

Creates a Duration of minutes.

common


fun durationOf(nanoseconds: Nanoseconds): Duration

Creates a Duration of nanoseconds.

common


fun durationOf(seconds: Seconds): Duration

Creates a Duration of seconds.

common


fun durationOf(seconds: Seconds, nanoseconds: Nanoseconds): Duration

Creates a Duration.
minus

common


operator fun Days.minus(period: Period): Period

operator fun Months.minus(period: Period): Period

operator fun Weeks.minus(period: Period): Period

operator fun Years.minus(period: Period): Period
periodOf

common


fun periodOf(days: Days): Period

fun periodOf(weeks: Weeks): Period

fun periodOf(months: Months, days: Days = 0.days): Period

fun periodOf(years: Years, days: Days): Period

fun periodOf(years: Years, months: Months = 0.months, days: Days = 0.days): Period

Creates a Period.
plus

common


operator fun Days.plus(period: Period): Period

operator fun Months.plus(period: Period): Period

operator fun Weeks.plus(period: Period): Period

operator fun Years.plus(period: Period): Period
times

common


operator fun Int.times(centuries: Centuries): Centuries

operator fun Long.times(centuries: Centuries): Centuries

Multiplies this value by a duration of centuries.

common


operator fun Int.times(days: Days): Days

operator fun Long.times(days: Days): Days

Multiplies this value by a duration of days.

common


operator fun Int.times(decades: Decades): Decades

operator fun Long.times(decades: Decades): Decades

Multiplies this value by a duration of decades.

common


operator fun Int.times(duration: Duration): Duration

Multiplies this value by a duration.

common


operator fun Int.times(hours: Hours): Hours

operator fun Long.times(hours: Hours): Hours

Multiplies this value by a duration of hours.

common


operator fun Int.times(microseconds: Microseconds): Microseconds

operator fun Long.times(microseconds: Microseconds): Microseconds

Multiplies this value by a duration of microseconds.

common


operator fun Int.times(milliseconds: Milliseconds): Milliseconds

operator fun Long.times(milliseconds: Milliseconds): Milliseconds

Multiplies this value by a duration of milliseconds.

common


operator fun Int.times(minutes: Minutes): Minutes

operator fun Long.times(minutes: Minutes): Minutes

Multiplies this value by a duration of minutes.

common


operator fun Int.times(months: Months): Months

operator fun Long.times(months: Months): Months

Multiplies this value by a duration of months.

common


operator fun Int.times(nanoseconds: Nanoseconds): Nanoseconds

operator fun Long.times(nanoseconds: Nanoseconds): Nanoseconds

Multiplies this value by a duration of nanoseconds.

common


operator fun Int.times(period: Period): Period

operator fun Long.times(period: Period): Period

common


operator fun Int.times(seconds: Seconds): Seconds

operator fun Long.times(seconds: Seconds): Seconds

Multiplies this value by a duration of seconds.

common


operator fun Int.times(weeks: Weeks): Weeks

operator fun Long.times(weeks: Weeks): Weeks

Multiplies this value by a duration of weeks.

common


operator fun Int.times(years: Years): Years

operator fun Long.times(years: Years): Years

Multiplies this value by a duration of years.
toDuration

common


fun String.toDuration(): Duration

Converts an ISO-8601 duration string to a Duration.

common


fun String.toDuration(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Duration

Converts a string to a Duration using parser.
toIslandDays

common


fun Duration.toIslandDays(): Days

Converts this duration to Island Time Days.
toIslandDuration

common


fun Duration.toIslandDuration(): Duration

Converts this duration to an equivalent Island Time Duration.
toIslandHours

common


fun Duration.toIslandHours(): Hours

Converts this duration to Island Time Hours.
toIslandMicroseconds

common


fun Duration.toIslandMicroseconds(): Microseconds

Converts this duration to Island Time Microseconds.
toIslandMilliseconds

common


fun Duration.toIslandMilliseconds(): Milliseconds

Converts this duration to Island Time Milliseconds.
toIslandMinutes

common


fun Duration.toIslandMinutes(): Minutes

Converts this duration to Island Time Minutes.
toIslandNanoseconds

common


fun Duration.toIslandNanoseconds(): Nanoseconds

Converts this duration to Island Time Nanoseconds.
toIslandSeconds

common


fun Duration.toIslandSeconds(): Seconds

Converts this duration to Island Time Seconds.
toPeriod

common


fun String.toPeriod(): Period

fun String.toPeriod(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Period