DateTime

value class DateTime(val unixMillis: Double) : Comparable<DateTime> , Serializable

Represents a Date in UTC (GMT+00) with millisecond precision.

It is internally represented as an inlined double, thus doesn't allocate in any target including JS. It can represent without loss dates between (-(2 ** 52) and (2 ** 52)):

  • Thu Aug 10 -140744 07:15:45 GMT-0014 (Central European Summer Time)

  • Wed May 23 144683 18:29:30 GMT+0200 (Central European Summer Time)

Constructors

Link copied to clipboard
constructor(unixMillis: Double)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val date: Date
Link copied to clipboard

Returns a DateTime of this day with the hour at 23:59:59.999

Link copied to clipboard

Returns a DateTime of this day with the hour at 00:00:00

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The dayOfWeek part as Int

Link copied to clipboard

The dayOfYear part

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

The hours part

Link copied to clipboard

Returns this date with the local offset of this device. Components might change because of the offset.

Link copied to clipboard

The local offset for this date for the timezone of the device

Link copied to clipboard

Returns a new local date that will match these components.

Link copied to clipboard
Link copied to clipboard

The minutes part

Link copied to clipboard

The Month part

Link copied to clipboard
val month0: Int

The Month part as Int where January is represented as 0

Link copied to clipboard
val month1: Int

The Month part as Int where January is represented as 1

Link copied to clipboard

Returns the quarter 1, 2, 3 or 4

Link copied to clipboard

The seconds part

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val time: Time
Link copied to clipboard

Number of milliseconds since UNIX EPOCH

Link copied to clipboard

Number of milliseconds since UNIX EPOCH as Double

Link copied to clipboard

Number of milliseconds since UNIX EPOCH as Long

Link copied to clipboard

Returns this date with a 0 offset. Components are equal.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val year: Year

The Year part

Link copied to clipboard

The Year part as Int

Link copied to clipboard

Represents a couple of Year and Month that has leap information and thus allows to get the number of days of that month

Link copied to clipboard

Number of milliseconds since the 00:00:00 UTC, Monday, 1 January 1

Functions

Link copied to clipboard
fun add(dateSpan: MonthSpan, timeSpan: TimeSpan): DateTime

Constructs a new DateTime after adding dateSpan and timeSpan

fun add(deltaMonths: Int, deltaMilliseconds: Double): DateTime

Constructs a new DateTime after adding deltaMonths and deltaMilliseconds

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open operator override fun compareTo(other: DateTime): Int
Link copied to clipboard
fun DateTime.convertRange(srcMin: DateTime, srcMax: DateTime, dstMin: DateTime, dstMax: DateTime): DateTime
Link copied to clipboard
fun copyDayOfMonth(year: Year = this.year, month: Month = this.month, dayOfMonth: Int = this.dayOfMonth, hours: Int = this.hours, minutes: Int = this.minutes, seconds: Int = this.seconds, milliseconds: Int = this.milliseconds): DateTime
Link copied to clipboard
Link copied to clipboard
fun format(format: DateFormat): String
fun format(format: String): String

Converts this date to String using format for representing it

Link copied to clipboard
fun DateTime.format(format: String, locale: KlockLocale): String
Link copied to clipboard
operator fun minus(other: DateTime): TimeSpan
operator fun minus(delta: DateTimeSpan): DateTime
operator fun minus(delta: MonthSpan): DateTime
operator fun minus(delta: TimeSpan): DateTime
Link copied to clipboard
operator fun plus(delta: DateTimeSpan): DateTime
operator fun plus(delta: MonthSpan): DateTime
operator fun plus(delta: TimeSpan): DateTime
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun DateTime.toNSDate(): NSDate
Link copied to clipboard

Returns this date with a local offset. Components might change because of the offset.

Link copied to clipboard

Returns a new local date that will match these components but with a different offset.

Link copied to clipboard
open override fun toString(): String

fun toString(format: DateFormat): String
fun toString(format: String): String

Converts this date to String using format for representing it

Link copied to clipboard

Converts this date to String using the DateFormat.DEFAULT_FORMAT for representing it

Link copied to clipboard

Generates a right-opened range between two DateTimes