core / io.islandtime.ranges / ZonedDateTimeInterval

ZonedDateTimeInterval

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) class ZonedDateTimeInterval : 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

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

<init>

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

<init>(start: ZonedDateTime = UNBOUNDED.start, endExclusive: ZonedDateTime = UNBOUNDED.endExclusive)

Properties

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthInDays

Get the number of whole days in the interval.

val lengthInDays: LongDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthInMonths

Get the number of months between the start and end of the interval. A month is considered to have passed if the day of the end month is greater than or equal to the day of the start month.

val lengthInMonths: IntMonths
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthInWeeks

Get the number of whole weeks in the interval.

val lengthInWeeks: LongWeeks
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthInYears

Get the number of years between the start and end of the interval. A year is considered to have passed if twelve full months have passed between the start date and end date.

val lengthInYears: IntYears

Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asPeriod

Converts this interval into a Period of the same length.

fun asPeriod(): Period
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

hasUnboundedEnd

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

fun hasUnboundedEnd(): Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

hasUnboundedStart

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

fun hasUnboundedStart(): Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toString

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

fun toString(): String

Companion Object Properties

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

EMPTY

An empty interval.

val EMPTY: ZonedDateTimeInterval
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

UNBOUNDED

An unbounded (ie. infinite) interval.

val UNBOUNDED: ZonedDateTimeInterval

Extension Functions

(jvm)

random

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

fun ZonedDateTimeInterval.random(random: Random): ZonedDateTime
(jvm)

randomOrNull

Return a random date-time within the 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.

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