//core/io.islandtime.ranges/DateTimeInterval
DateTimeInterval¶
common
@Serializable(with = DateTimeIntervalIsoSerializer::class)
class DateTimeInterval(val start: DateTime = UNBOUNDED.start, val endExclusive: DateTime = UNBOUNDED.endExclusive) : Interval<DateTime>
An interval between two date-times, assumed to be at the same offset from UTC.
DateTime.MIN and DateTime.MAX are used as sentinels to indicate an unbounded (i.e. infinite) start or end.
Constructors¶
| DateTimeInterval | common constructor(start: DateTime = UNBOUNDED.start, endExclusive: DateTime = UNBOUNDED.endExclusive) |
Types¶
| Name | Summary |
|---|---|
| Companion | common object Companion |
Properties¶
| Name | Summary |
|---|---|
| endExclusive | common open override val endExclusive: DateTimeThe end of this interval, exclusive. |
| endInclusive | common open override val endInclusive: DateTimeThe end of this interval, inclusive. |
| lengthInCenturies | common val DateTimeInterval.lengthInCenturies: CenturiesThe number of whole centuries between the start and end of this interval. |
| lengthInDays | common val DateTimeInterval.lengthInDays: DaysThe number of whole days between the start and end of this interval. |
| lengthInDecades | common val DateTimeInterval.lengthInDecades: DecadesThe number of whole decades between the start and end of this interval. |
| lengthInHours | common val DateTimeInterval.lengthInHours: HoursThe number of whole hours between the start and end of this interval. |
| lengthInMicroseconds | common val DateTimeInterval.lengthInMicroseconds: MicrosecondsThe number of whole microseconds between the start and end of this interval. |
| lengthInMilliseconds | common val DateTimeInterval.lengthInMilliseconds: MillisecondsThe number of whole milliseconds between the start and end of this interval. |
| lengthInMinutes | common val DateTimeInterval.lengthInMinutes: MinutesThe number of whole minutes between the start and end of this interval. |
| lengthInMonths | common val DateTimeInterval.lengthInMonths: MonthsThe number of whole months between the start and end of this interval. |
| lengthInNanoseconds | common val DateTimeInterval.lengthInNanoseconds: NanosecondsThe number of nanoseconds between the start and end of this interval. |
| lengthInSeconds | common val DateTimeInterval.lengthInSeconds: SecondsThe number of whole seconds between the start and end of this interval. |
| lengthInWeeks | common val DateTimeInterval.lengthInWeeks: WeeksThe number of whole weeks between the start and end of this interval. |
| lengthInYears | common val DateTimeInterval.lengthInYears: YearsThe number of whole years between the start and end of this interval. |
| start | common open override val start: DateTimeThe start of this interval, inclusive. |
Functions¶
| Name | Summary |
|---|---|
| at | common infix fun DateTimeInterval.at(zone: TimeZone): ZonedDateTimeIntervalCombines this DateTimeInterval with a TimeZone to create a ZonedDateTimeInterval where both endpoints are in zone. |
| contains | common open operator override fun contains(value: DateTime): BooleanChecks if this interval contains value. |
| contains | common fun <T> Interval<T>.contains(value: T?): BooleanChecks if this interval contains value. |
| equals | common open operator override fun equals(other: Any?): Boolean |
| hasBoundedEnd | common open fun hasBoundedEnd(): BooleanChecks if this interval's end is bounded, meaning it has a finite value. |
| hasBoundedStart | common open fun hasBoundedStart(): BooleanChecks 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(): BooleanChecks if this interval's end is unbounded. In ISO-8601 terminology, this is an "open" end. |
| hasUnboundedStart | common open override fun hasUnboundedStart(): BooleanChecks if this interval's start is unbounded. In ISO-8601 terminology, this is an "open" start. |
| isBounded | common open fun isBounded(): BooleanChecks if both the start and end of this interval are bounded, meaning it has a finite range. |
| isEmpty | common open override fun isEmpty(): BooleanChecks if this interval is empty. |
| isUnbounded | common open fun isUnbounded(): BooleanChecks if both the start and end of this interval are unbounded, meaning this is an infinite time period in both directions. |
| random | common fun DateTimeInterval.random(): DateTimeReturns a random date within this interval using the default random number generator. common fun DateTimeInterval.random(random: Random): DateTimeReturns a random date within this interval using the supplied random number generator. |
| randomOrNull | common fun DateTimeInterval.randomOrNull(): DateTime?Returns a random date within this interval using the default random number generator or null if the interval is empty or unbounded.common fun DateTimeInterval.randomOrNull(random: Random): DateTime?Returns a random date within this interval using the supplied random number generator or null if the interval is empty or unbounded. |
| toDateRange | common fun DateTimeInterval.toDateRange(): DateRangeReturns this interval with the precision reduced to just the date. |
| toDuration | common fun DateTimeInterval.toDuration(): DurationConverts 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. |
| toInstantIntervalAt | common fun DateTimeInterval.toInstantIntervalAt(zone: TimeZone): InstantIntervalConverts this interval to an InstantInterval where both endpoints are in zone. |
| toPeriod | common fun DateTimeInterval.toPeriod(): PeriodConverts this interval into a Period of the same length. |
| toString | common open override fun toString(): StringConverts this interval to a string in ISO-8601 extended format. |