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
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 day of week part as Int : 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday

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
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

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 DateTime.add(dateSpan: MonthSpan, duration: Duration): DateTime

Constructs a new DateTime after adding dateSpan and duration

fun DateTime.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 DateTime.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
Link copied to clipboard

Converts this date to String using format for representing it

fun DateTime.format(format: String, locale: KlockLocale): String
Link copied to clipboard
operator fun minus(other: DateTime): Duration
operator fun minus(delta: FastDuration): DateTime
operator fun minus(delta: Duration): DateTime
Link copied to clipboard
operator fun DateTime.minus(delta: DateTimeSpan): DateTime
operator fun DateTime.minus(delta: MonthSpan): DateTime
Link copied to clipboard
operator fun plus(delta: FastDuration): DateTime
operator fun plus(delta: Duration): DateTime
Link copied to clipboard
operator fun DateTime.plus(delta: DateTimeSpan): DateTime
operator fun DateTime.plus(delta: MonthSpan): 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
Link copied to clipboard

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

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

Link copied to clipboard

Generates a right-opened range between two DateTimes