DateTimeSpan

data class DateTimeSpan(val monthSpan: MonthSpan, val timeSpan: TimeSpan) : Comparable<DateTimeSpan> , Serializable

Immutable structure representing a set of a monthSpan and a timeSpan. This structure loses information about which months are included, that makes it impossible to generate a real TimeSpan including months. You can use DateTimeRange.duration to get this information from two real DateTime.

Constructors

Link copied to clipboard
constructor(years: Int = 0, months: Int = 0, weeks: Int = 0, days: Int = 0, hours: Int = 0, minutes: Int = 0, seconds: Int = 0, milliseconds: Double = 0.0)
constructor(monthSpan: MonthSpan, timeSpan: TimeSpan)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val days: Int

The days part as an integer.

Link copied to clipboard

The daysIncludingWeeks part as an integer including days and weeks.

Link copied to clipboard
Link copied to clipboard
val hours: Int

The hours part as an integer.

Link copied to clipboard

The milliseconds part as a double.

Link copied to clipboard

The minutes part as an integer.

Link copied to clipboard
val months: Int

The months part as an integer.

Link copied to clipboard
Link copied to clipboard

The seconds part as an integer.

Link copied to clipboard

The secondsIncludingMilliseconds part as a doble including seconds and milliseconds.

Link copied to clipboard
Link copied to clipboard

From the time part, all the milliseconds including milliseconds, seconds, minutes, hours, days and weeks

Link copied to clipboard

From the date part, all months including months and years

Link copied to clipboard

From the date part, all months represented as a totalYears

Link copied to clipboard
val weeks: Int

The weeks part as an integer.

Link copied to clipboard
val years: Int

The years part as an integer.

Functions

Link copied to clipboard
open operator override fun compareTo(other: DateTimeSpan): Int

Note that if milliseconds overflow months this could not be exactly true. But probably will work in most cases. This structure doesn't have information about which months are counted. So some months could have 28-31 days and thus can't be done. You can use DateTimeRange.duration to compare this with real precision using a range between two DateTime.

Link copied to clipboard
operator fun div(times: Double): DateTimeSpan
operator fun div(times: Float): DateTimeSpan
operator fun div(times: Int): DateTimeSpan
Link copied to clipboard
operator fun minus(other: DateTimeSpan): DateTimeSpan
operator fun minus(other: MonthSpan): DateTimeSpan
operator fun minus(other: TimeSpan): DateTimeSpan
Link copied to clipboard
operator fun plus(other: DateTimeSpan): DateTimeSpan
operator fun plus(other: MonthSpan): DateTimeSpan
operator fun plus(other: TimeSpan): DateTimeSpan
Link copied to clipboard
operator fun times(times: Double): DateTimeSpan
operator fun times(times: Float): DateTimeSpan
operator fun times(times: Int): DateTimeSpan
Link copied to clipboard
open override fun toString(): String

fun toString(includeWeeks: Boolean): String

Represents this DateTimeSpan as a string like 50Y 10M 3W 6DH 30m 15s. Parts that are zero, won't be included. You can omit weeks and represent them as days by adjusting the includeWeeks parameter.

Link copied to clipboard
operator fun unaryMinus(): DateTimeSpan
Link copied to clipboard
operator fun unaryPlus(): DateTimeSpan