Skip to content

//core/io.islandtime.ranges/toDuration

toDuration

common

fun DateTimeInterval.toDuration(): Duration

Converts this interval to the Duration between the start and end date-time, which are assumed to be in the same time zone. In general, it's more appropriate to calculate duration using Instant or ZonedDateTime as any daylight savings rules won't be taken into account when working with DateTime directly.

Throws

UnsupportedOperationException if the interval isn't bounded

common

fun TimePointInterval<*>.toDuration(): Duration

Converts this interval into a Duration of the same length.

Throws

UnsupportedOperationException if the interval isn't bounded