core / io.islandtime

Package io.islandtime

Date-time primitives and core concepts, such as Date, Time, Instant, and ZonedDateTime.

Types

(iosArm64, iosX64, jvm, macosX64)

Date

A date in an arbitrary region.

class Date : Comparable<Date>
(iosArm64, iosX64, jvm, macosX64)

DateTime

A date and time of day in an arbitrary region.

class DateTime : Comparable<DateTime>

DateTimeException

(iosArm64, iosX64, macosX64) open class DateTimeException
(jvm) open class DateTimeException : Exception
(iosArm64, iosX64, jvm, macosX64)

DayOfWeek

A day of the week.

enum class DayOfWeek
(iosArm64, iosX64, jvm, macosX64)

Instant

An instant in time with nanosecond precision.

class Instant : TimePoint<Instant>, Comparable<Instant>
(iosArm64, iosX64, jvm, macosX64)

IslandTime

object IslandTime
(iosArm64, iosX64, jvm, macosX64)

Month

A month of the year.

enum class Month
(iosArm64, iosX64, jvm, macosX64)

OffsetDateTime

A date and time of day with an offset from UTC.

class OffsetDateTime : TimePoint<OffsetDateTime>
(iosArm64, iosX64, jvm, macosX64)

OffsetTime

A time of day with an offset from UTC.

class OffsetTime
(iosArm64, iosX64, jvm, macosX64)

Time

A time of day in an arbitrary region.

class Time : Comparable<Time>
(iosArm64, iosX64, jvm, macosX64)

TimeZone

A time zone.

sealed class TimeZone : Comparable<TimeZone>
(iosArm64, iosX64, jvm, macosX64)

UtcOffset

The time shift between a local time and UTC.

class UtcOffset : Comparable<UtcOffset>
(iosArm64, iosX64, jvm, macosX64)

Year

class Year : Comparable<Year>
(iosArm64, iosX64, jvm, macosX64)

YearMonth

A month in a particular year.

class YearMonth : Comparable<YearMonth>
(iosArm64, iosX64, jvm, macosX64)

ZonedDateTime

A date and time of day in a particular region.

class ZonedDateTime : TimePoint<ZonedDateTime>

Extensions for External Classes

(iosArm64, iosX64, jvm, macosX64)

kotlin.Int

(iosArm64, iosX64, jvm, macosX64)

kotlin.String

Properties

(iosArm64, iosX64, jvm, macosX64)

endOfDay

The DateTime at the end of the day.

val Date.endOfDay: DateTime
(iosArm64, iosX64, jvm, macosX64)

startOfDay

The DateTime at the start of the day.

val Date.startOfDay: DateTime

Functions

(iosArm64, iosX64, jvm, macosX64)

asOffsetDateTime

Convert to an OffsetDateTime with the same date, time of day, and offset.

fun ZonedDateTime.asOffsetDateTime(): OffsetDateTime
(iosArm64, iosX64, jvm, macosX64)

asTimeZone

Convert a UTC offset into a TimeZone with a fixed offset.

fun UtcOffset.asTimeZone(): TimeZone
(iosArm64, iosX64, jvm, macosX64)

asUtcOffset

Convert a duration of hours into a UTC time offset of the same length.

fun IntHours.asUtcOffset(): UtcOffset

Convert a duration of minutes into a UTC time offset of the same length.

fun IntMinutes.asUtcOffset(): UtcOffset

Convert a duration of seconds into a UTC time offset of the same length.

fun IntSeconds.asUtcOffset(): UtcOffset
(iosArm64, iosX64, jvm, macosX64)

asZonedDateTime

Convert to a ZonedDateTime with a fixed time zone.

fun OffsetDateTime.asZonedDateTime(): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64)

at

Combine a Date with a Time to create a DateTime.

infix fun Date.at(time: Time): DateTimeinfix fun DateTime.at(offset: UtcOffset): OffsetDateTime
infix fun Date.at(offsetTime: OffsetTime): OffsetDateTime
infix fun Instant.at(offset: UtcOffset): OffsetDateTime

Create an OffsetTime by combining a Time with a UtcOffset.

infix fun Time.at(offset: UtcOffset): OffsetTime

Combine a year and month to get a YearMonth.

infix fun Year.at(month: Month): YearMonth

Get the ZonedDateTime corresponding to the local date and time in a particular time zone.

infix fun DateTime.at(zone: TimeZone): ZonedDateTime

Get the ZonedDateTime representing an instant in a particular time zone.

infix fun Instant.at(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64)

atDay

fun YearMonth.atDay(day: Int): Date
(iosArm64, iosX64, jvm, macosX64)

atMonth

Combine a year and month number to get a YearMonth.

fun Year.atMonth(number: Int): YearMonth
(iosArm64, iosX64, jvm, macosX64)

atTime

Combine a Date with a time to create a DateTime.

fun Date.atTime(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0): DateTime
(iosArm64, iosX64, jvm, macosX64)

Date

Create a Date from a year and day of year

fun Date(year: Int, dayOfYear: Int): Date
(iosArm64, iosX64, jvm, macosX64)

endOfDayAt

The ZonedDateTime at the last representable instant of this date in a particular time zone.

fun Date.endOfDayAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64)

Instant

Create the Instant represented by a number of seconds relative to the Unix epoch of 1970-01-01T00:00Z.

fun Instant(secondsSinceUnixEpoch: LongSeconds): Instant

Create the Instant represented by a number of seconds and additional nanoseconds relative to the Unix epoch of 1970-01-01T00:00Z.

fun Instant(secondsSinceUnixEpoch: LongSeconds, nanosecondAdjustment: IntNanoseconds): Instant
fun Instant(secondsSinceUnixEpoch: LongSeconds, nanosecondAdjustment: LongNanoseconds): Instant

Create the Instant represented by a number of milliseconds relative to the Unix epoch of 1970-01-01T00:00Z.

fun Instant(millisecondsSinceUnixEpoch: LongMilliseconds): Instant
(iosArm64, iosX64, jvm, macosX64)

sameInstantAt

Get the ZonedDateTime corresponding to the same instant represented by an OffsetDateTime in a particular time zone

fun OffsetDateTime.sameInstantAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64)

similarLocalTimeAt

Get the ZonedDateTime corresponding to a local date, time, and offset in a particular time zone. The offset will be preserved if it is valid based on the rules of the time zone.

fun OffsetDateTime.similarLocalTimeAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64)

startOfDayAt

The ZonedDateTime at the start of this date in a particular time zone, taking into account

fun Date.startOfDayAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64)

TimeZone

Create a TimeZone from an identifier.

fun TimeZone(id: String): TimeZone
(iosArm64, iosX64, jvm, macosX64)

toDateAt

fun Instant.toDateAt(offset: UtcOffset): Date
fun Instant.toDateAt(zone: TimeZone): Date
(iosArm64, iosX64, jvm, macosX64)

toDateTimeAt

Convert an instant into a DateTime at a particular offset from UTC.

fun Instant.toDateTimeAt(offset: UtcOffset): DateTime
(iosArm64, iosX64, jvm, macosX64)

UtcOffset

Create a UTC offset of hours, minutes, and seconds. Each component must be within its valid range and without any mixed positive and negative values.

fun UtcOffset(hours: IntHours, minutes: IntMinutes = 0.minutes, seconds: IntSeconds = 0.seconds): UtcOffset
(iosArm64, iosX64, jvm, macosX64)

ZonedDateTime

Create a ZonedDateTime from a local date and time.

fun ZonedDateTime(year: Int, month: Month, day: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(year: Int, monthNumber: Int, day: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(year: Int, dayOfYear: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(date: Date, time: Time, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(dateTime: DateTime, zone: TimeZone): ZonedDateTime