core / io.islandtime

Package io.islandtime

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

Types

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

Date

A date in an ambiguous region.

class Date : Comparable<Date>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DateTime

A date and time of day in an ambiguous region.

class DateTime : Comparable<DateTime>

DateTimeException

(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) open class DateTimeException
(jvm) open class DateTimeException : Exception
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

DayOfWeek

A day of the week.

enum class DayOfWeek
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

Instant

An instant in time with nanosecond precision.

class Instant : TimePoint<Instant>, Comparable<Instant>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

IslandTime

Global configuration for Island Time.

object IslandTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

Month

A month of the year.

enum class Month
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

OffsetConversionStrategy

Strategy to use when converting a local date-time accompanied by a UtcOffset to a date and time that are valid according to the rules of a TimeZone.

enum class OffsetConversionStrategy
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

OffsetDateTime

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

class OffsetDateTime : TimePoint<OffsetDateTime>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

OffsetTime

A time of day with an offset from UTC.

class OffsetTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

Time

A time of day in an ambiguous region.

class Time : Comparable<Time>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimeZone

A time zone.

sealed class TimeZone : Comparable<TimeZone>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

UtcOffset

The time shift between a local time and UTC.

class UtcOffset : Comparable<UtcOffset>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

Year

class Year : Comparable<Year>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

YearMonth

A month in a particular year.

class YearMonth : Comparable<YearMonth>
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

ZonedDateTime

A date and time of day in a particular region.

class ZonedDateTime : TimePoint<ZonedDateTime>

Extensions for External Classes

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

kotlin.Int

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

kotlin.String

Properties

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

endOfDay

The DateTime at the end of the day.

val Date.endOfDay: DateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

startOfDay

The DateTime at the start of the day.

val Date.startOfDay: DateTime

Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asOffsetDateTime

fun ZonedDateTime.asOffsetDateTime(): OffsetDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asTimeZone

Converts this UtcOffset into a fixed-offset TimeZone.

fun UtcOffset.asTimeZone(): TimeZone
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asUtcOffset

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

fun IntHours.asUtcOffset(): UtcOffset

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

fun IntMinutes.asUtcOffset(): UtcOffset

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

fun IntSeconds.asUtcOffset(): UtcOffset
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

asZonedDateTime

Converts this OffsetDateTime to an equivalent ZonedDateTime using a fixed-offset time zone.

fun OffsetDateTime.asZonedDateTime(): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

at

Combine a Date with a Time to create a DateTime.

infix fun Date.at(time: Time): DateTime

Combine a local date and time with a UTC offset to create an OffsetDateTime.

infix fun DateTime.at(offset: UtcOffset): OffsetDateTime

Combine a local date with a time and UTC offset to create an OffsetDateTime.

infix fun Date.at(offsetTime: OffsetTime): OffsetDateTime

Combine an instant with a UTC offset to create an OffsetDateTime.

infix fun Instant.at(offset: UtcOffset): OffsetDateTime

Combine a local time with a UTC offset to create an OffsetTime.

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

Combine a year and month to create a YearMonth.

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

Combine an instant with a time zone to create a ZonedDateTime.

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

Combine a local date and time with a time zone to create a ZonedDateTime.

infix fun DateTime.at(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

atDay

Combine a YearMonth with a day of the month to create a Date.

fun YearMonth.atDay(day: Int): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

atMonth

Combine a year and month number to create a YearMonth.

fun Year.atMonth(number: Int): YearMonth
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

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, tvosArm64, tvosX64, watchosArm64, watchosX86)

Date

Create a Date from a year and day of year

fun Date(year: Int, dayOfYear: Int): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dateTimeAt

fun OffsetDateTime.dateTimeAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

endOfDayAt

The ZonedDateTime at the last representable instant of this date in a particular time zone, taking into account any daylight savings transitions.

fun Date.endOfDayAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

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, tvosArm64, tvosX64, watchosArm64, watchosX86)

instantAt

fun OffsetDateTime.instantAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

sameInstantAt

fun OffsetDateTime.sameInstantAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

similarLocalTimeAt

fun OffsetDateTime.similarLocalTimeAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

startOfDayAt

The ZonedDateTime at the start of this date in a particular time zone, taking into account any daylight savings transitions.

fun Date.startOfDayAt(zone: TimeZone): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

TimeZone

Create a TimeZone from an identifier.

fun TimeZone(id: String): TimeZone
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toDateAt

Convert an Instant into the Date represented by it at a particular UTC offset.

fun Instant.toDateAt(offset: UtcOffset): Date

Convert an Instant into the Date represented by it in a particular time zone.

fun Instant.toDateAt(zone: TimeZone): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toDateTimeAt

Converts this instant to the corresponding DateTime in zone.

fun Instant.toDateTimeAt(zone: TimeZone): DateTime

Converts this instant to the corresponding DateTime at offset.

fun Instant.toDateTimeAt(offset: UtcOffset): DateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toInstant

Converts this date-time to the Instant representing the same time point.

fun OffsetDateTime.toInstant(): Instant
fun ZonedDateTime.toInstant(): Instant
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toInstantAt

Converts this date-time to the corresponding Instant at offset.

fun DateTime.toInstantAt(offset: UtcOffset): Instant
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toOffsetDateTime

Returns the combined date, time, and UTC offset.

fun ZonedDateTime.toOffsetDateTime(): OffsetDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toOffsetTime

Returns the combined time and UTC offset.

fun OffsetDateTime.toOffsetTime(): OffsetTime
fun ZonedDateTime.toOffsetTime(): OffsetTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toYear

Returns this date with the precision reduced to the year.

fun YearMonth.toYear(): Year
fun Date.toYear(): Year

Returns this date-time with the precision reduced to the year.

fun DateTime.toYear(): Year
fun OffsetDateTime.toYear(): Year
fun ZonedDateTime.toYear(): Year
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toYearMonth

Returns this date with the precision reduced to the year-month.

fun Date.toYearMonth(): YearMonth

Returns this date-time with the precision reduced to the year-month.

fun DateTime.toYearMonth(): YearMonth
fun OffsetDateTime.toYearMonth(): YearMonth
fun ZonedDateTime.toYearMonth(): YearMonth
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

toZonedDateTime

Converts this OffsetDateTime to a ZonedDateTime using the specified strategy to adjust it to a valid date, time, and offset in zone.

fun OffsetDateTime.toZonedDateTime(zone: TimeZone, strategy: OffsetConversionStrategy): ZonedDateTime
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

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, tvosArm64, tvosX64, watchosArm64, watchosX86)

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