Skip to content

//core/io.islandtime.ranges/ZonedDateTimeInterval

ZonedDateTimeInterval

common

class ZonedDateTimeInterval(start: ZonedDateTime, endExclusive: ZonedDateTime) : TimePointInterval<ZonedDateTime>

A half-open interval of zoned date-times based on timeline order.

DateTime.MIN and DateTime.MAX are used as sentinels to indicate an unbounded (ie. infinite) start or end. A ZonedDateTime with either as the date-time component will be treated accordingly, regardless of the offset or time zone.

Constructors

ZonedDateTimeInterval

common

fun ZonedDateTimeInterval(start: ZonedDateTime = UNBOUNDED.start, endExclusive: ZonedDateTime = UNBOUNDED.endExclusive)

Types

Name Summary
Companion

common


object Companion

Functions

Name Summary
contains

common


open operator override fun contains(value: ZonedDateTime): Boolean

Checks if this interval contains value.
equals

common


open operator override fun equals(other: Any?): Boolean
hasBoundedEnd

common


open fun hasBoundedEnd(): Boolean

Checks if this interval's end is bounded, meaning it has a finite value.
hasBoundedStart

common


open fun hasBoundedStart(): Boolean

Checks if this interval's start is bounded, meaning it has a finite value.
hashCode

common


open override fun hashCode(): Int
hasUnboundedEnd

common


open override fun hasUnboundedEnd(): Boolean

Checks if this interval's end is unbounded. In ISO-8601 terminology, this is an "open" end.
hasUnboundedStart

common


open override fun hasUnboundedStart(): Boolean

Checks if this interval's start is unbounded. In ISO-8601 terminology, this is an "open" start.
isBounded

common


open fun isBounded(): Boolean

Checks if both the start and end of this interval are bounded, meaning it has a finite range.
isEmpty

common


open override fun isEmpty(): Boolean

Checks if this interval is empty.
isUnbounded

common


open fun isUnbounded(): Boolean

Checks if both the start and end of this interval are unbounded, meaning this is an infinite time period in both directions.
toString

common


open override fun toString(): String

Converts this interval to a string in ISO-8601 extended format.

Properties

Name Summary
endExclusive

common

open override val endExclusive: ZonedDateTime

The end of this interval, exclusive.
endInclusive

common

open override val endInclusive: ZonedDateTime

The end of this interval, inclusive.
start

common

open override val start: ZonedDateTime

The start of this interval, inclusive.

Extensions

Name Summary
lengthInCenturies

common


val ZonedDateTimeInterval.lengthInCenturies: Centuries

The number of whole centuries between the start and end of this interval.
lengthInDays

common


val ZonedDateTimeInterval.lengthInDays: Days

The number of whole days between the start and end of this interval.
lengthInDecades

common


val ZonedDateTimeInterval.lengthInDecades: Decades

The number of whole decades between the start and end of this interval.
lengthInMonths

common


val ZonedDateTimeInterval.lengthInMonths: Months

The number of whole months between the start and end of this interval.
lengthInWeeks

common


val ZonedDateTimeInterval.lengthInWeeks: Weeks

The number of whole weeks between the start and end of this interval.
lengthInYears

common


val ZonedDateTimeInterval.lengthInYears: Years

The number of whole years between the start and end of this interval.
random

common


fun ZonedDateTimeInterval.random(): ZonedDateTime

Returns a random date within this interval using the default random number generator. The zone of the start date-time will be used.

common


fun ZonedDateTimeInterval.random(random: Random): ZonedDateTime

Returns a random date within this interval using the supplied random number generator. The zone of the start date-time will be used.
randomOrNull

common


fun ZonedDateTimeInterval.randomOrNull(): ZonedDateTime?

Returns a random date within this interval using the default random number generator or null if the interval is empty or unbounded. The zone of the start date-time will be used.

common


fun ZonedDateTimeInterval.randomOrNull(random: Random): ZonedDateTime?

Returns a random date within this interval using the supplied random number generator or null if the interval is empty or unbounded. The zone of the start date-time will be used.
toDateRange

common


fun ZonedDateTimeInterval.toDateRange(): DateRange

Returns this interval with the precision reduced to just the date.
toDateTimeInterval

common


fun ZonedDateTimeInterval.toDateTimeInterval(): DateTimeInterval

Returns this interval with the precision reduced to only the local date and time.
toInstantInterval

common


fun ZonedDateTimeInterval.toInstantInterval(): InstantInterval

Converts this interval to an InstantInterval.
toOffsetDateTimeInterval

common


fun ZonedDateTimeInterval.toOffsetDateTimeInterval(): OffsetDateTimeInterval

Converts this interval to an OffsetDateTimeInterval.
toPeriod

common


fun ZonedDateTimeInterval.toPeriod(): Period

Converts this interval into a Period of the same length.