Package io.islandtime.measures

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

Types

Centuries
Link copied to clipboard
common
value class Centuries(value: Long) : Comparable<Centuries>
Days
Link copied to clipboard
common
value class Days(value: Long) : Comparable<Days>
Decades
Link copied to clipboard
common
value class Decades(value: Long) : Comparable<Decades>
Duration
Link copied to clipboard
common
class Duration : Comparable<Duration>

A duration of time at nanosecond precision.

Hours
Link copied to clipboard
common
value class Hours(value: Long) : Comparable<Hours>
Microseconds
Link copied to clipboard
common
value class Microseconds(value: Long) : Comparable<Microseconds>
Milliseconds
Link copied to clipboard
common
value class Milliseconds(value: Long) : Comparable<Milliseconds>
Minutes
Link copied to clipboard
common
value class Minutes(value: Long) : Comparable<Minutes>
Months
Link copied to clipboard
common
value class Months(value: Long) : Comparable<Months>
Nanoseconds
Link copied to clipboard
common
value class Nanoseconds(value: Long) : Comparable<Nanoseconds>
Period
Link copied to clipboard
common
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
Link copied to clipboard
common
value class Seconds(value: Long) : Comparable<Seconds>
TimeUnit
Link copied to clipboard
common
enum TimeUnit : Enum<TimeUnit>

A unit of time measurement.

Weeks
Link copied to clipboard
common
value class Weeks(value: Long) : Comparable<Weeks>
Years
Link copied to clipboard
common
value class Years(value: Long) : Comparable<Years>

Functions

abs
Link copied to clipboard
common
fun abs(duration: Duration): Duration

Returns the absolute value of a duration.

asDuration
Link copied to clipboard
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
Link copied to clipboard
common
fun Days.asPeriod(): Period

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

fun Months.asPeriod(): Period

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

fun Weeks.asPeriod(): Period

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

fun Years.asPeriod(): Period

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

durationOf
Link copied to clipboard
common
fun durationOf(days: Days): Duration

Creates a Duration of 24-hour days.

fun durationOf(hours: Hours): Duration

Creates a Duration of hours.

fun durationOf(microseconds: Microseconds): Duration

Creates a Duration of microseconds.

fun durationOf(milliseconds: Milliseconds): Duration

Creates a Duration of milliseconds.

fun durationOf(minutes: Minutes): Duration

Creates a Duration of minutes.

fun durationOf(nanoseconds: Nanoseconds): Duration

Creates a Duration of nanoseconds.

fun durationOf(seconds: Seconds): Duration

Creates a Duration of seconds.

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

Creates a Duration.

minus
Link copied to clipboard
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
Link copied to clipboard
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
Link copied to clipboard
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
Link copied to clipboard
common
operator fun Int.times(centuries: Centuries): Centuries
operator fun Long.times(centuries: Centuries): Centuries

Multiplies this value by a duration of centuries. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of days. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of decades. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration.

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

Multiplies this value by a duration of hours. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of microseconds. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of milliseconds. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of minutes. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of months. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of nanoseconds. @throws ArithmeticException if overflow occurs

operator fun Int.times(period: Period): Period
operator fun Long.times(period: Period): Period
operator fun Int.times(seconds: Seconds): Seconds
operator fun Long.times(seconds: Seconds): Seconds

Multiplies this value by a duration of seconds. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of weeks. @throws ArithmeticException if overflow occurs

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

Multiplies this value by a duration of years. @throws ArithmeticException if overflow occurs

toDuration
Link copied to clipboard
common
fun String.toDuration(): Duration

Converts an ISO-8601 duration string to a Duration.

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

Converts a string to a Duration using parser.

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

Converts this duration to Island Time Days.

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

Converts this duration to an equivalent Island Time Duration.

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

Converts this duration to Island Time Hours.

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

Converts this duration to Island Time Microseconds.

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

Converts this duration to Island Time Milliseconds.

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

Converts this duration to Island Time Minutes.

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

Converts this duration to Island Time Nanoseconds.

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

Converts this duration to Island Time Seconds.

toPeriod
Link copied to clipboard
common
fun String.toPeriod(): Period
fun String.toPeriod(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Period

Properties

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

Converts this value to a duration of centuries.

centuries
Link copied to clipboard
common
val Long.centuries: Centuries

Converts this value to a duration of centuries.

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

Converts this value to a duration of days.

days
Link copied to clipboard
common
val Long.days: Days

Converts this value to a duration of days.

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

Converts this value to a duration of decades.

decades
Link copied to clipboard
common
val Long.decades: Decades

Converts this value to a duration of decades.

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

Converts this value to a duration of hours.

hours
Link copied to clipboard
common
val Long.hours: Hours

Converts this value to a duration of hours.

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

Converts this value to a duration of microseconds.

microseconds
Link copied to clipboard
common
val Long.microseconds: Microseconds

Converts this value to a duration of microseconds.

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

Converts this value to a duration of milliseconds.

milliseconds
Link copied to clipboard
common
val Long.milliseconds: Milliseconds

Converts this value to a duration of milliseconds.

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

Converts this value to a duration of minutes.

minutes
Link copied to clipboard
common
val Long.minutes: Minutes

Converts this value to a duration of minutes.

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

Converts this value to a duration of months.

months
Link copied to clipboard
common
val Long.months: Months

Converts this value to a duration of months.

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

Converts this value to a duration of nanoseconds.

nanoseconds
Link copied to clipboard
common
val Long.nanoseconds: Nanoseconds

Converts this value to a duration of nanoseconds.

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

Converts this value to a duration of seconds.

seconds
Link copied to clipboard
common
val Long.seconds: Seconds

Converts this value to a duration of seconds.

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

Converts this value to a duration of weeks.

weeks
Link copied to clipboard
common
val Long.weeks: Weeks

Converts this value to a duration of weeks.

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

Converts this value to a duration of years.

years
Link copied to clipboard
common
val Long.years: Years

Converts this value to a duration of years.