Package-level declarations

Types

Link copied to clipboard
value class Date(val encoded: Int) : Comparable<Date> , Serializable

Represents a triple of year, month and day.

Link copied to clipboard

An exception for Date operations.

Link copied to clipboard
interface DateFormat

Allows to format and parse instances of Date, DateTime and DateTimeTz

Link copied to clipboard
value class DateTime(val unixMillis: Double) : Comparable<DateTime> , Serializable

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

Link copied to clipboard
data class DateTimeRange(val from: DateTime, val to: DateTime) : Comparable<DateTime> , Serializable

Represents a right-opened range between two dates.

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

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

Represents the day of the week. Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

Link copied to clipboard
data class DayOfWeekWithLocale(val dayOfWeek: DayOfWeek, val locale: KlockLocale) : Comparable<DayOfWeekWithLocale>
Link copied to clipboard
Link copied to clipboard
class IntTimedCache(val ttl: TimeSpan, val timeProvider: TimeProvider = TimeProvider, val gen: () -> Int)
Link copied to clipboard
object ISO8601
Link copied to clipboard
abstract class KlockLocale
Link copied to clipboard
data class KlockLocaleContext(val gender: KlockLocaleGender = KlockLocaleGender.Neuter)
Link copied to clipboard
Link copied to clipboard

Represents one of the twelve months of the year.

Link copied to clipboard
value class MonthSpan(val totalMonths: Int) : Comparable<MonthSpan> , Serializable

Represents a number of years and months temporal distance.

Link copied to clipboard
value class NumberOfTimes(val count: Int)
Link copied to clipboard
data class PatternDateFormat @JvmOverloads constructor(val format: String, val locale: KlockLocale? = null, val tzNames: TimezoneNames = TimezoneNames.DEFAULT, val options: PatternDateFormat.Options = Options.DEFAULT) : DateFormat, Serializable
Link copied to clipboard
data class PatternTimeFormat(val format: String, val options: PatternTimeFormat.Options = Options.DEFAULT) : TimeFormat, Serializable
Link copied to clipboard

Class for measuring relative times with as much precision as possible.

Link copied to clipboard
class Stopwatch(val nanosecondProvider: () -> Double = { PerformanceCounter.nanoseconds })
Link copied to clipboard
value class Time(val encoded: TimeSpan) : Comparable<Time> , Serializable

Represents a union of millisecond, second, minute and hour.

Link copied to clipboard
class TimedCache<T : Any>(var ttl: TimeSpan, val timeProvider: TimeProvider = TimeProvider, val gen: () -> T)
Link copied to clipboard
data class TimedResult<T>(val result: T, val time: TimeSpan)

Represents a result associated to a time.

Link copied to clipboard
interface TimeFormat
Link copied to clipboard
interface TimeProvider

Class to provide time that can be overridden to mock or change its behaviour.

Link copied to clipboard
class TimeSampler(var timeWindow: TimeSpan = 1.seconds)

Class to count the number of times a sample was added in a timeWindow

Link copied to clipboard
typealias TimeSpan = Duration

Represents a span of time, with milliseconds precision.

Link copied to clipboard
data class TimezoneNames(val namesToOffsets: Map<String, TimeSpan>) : Serializable
Link copied to clipboard
value class TimezoneOffset(val totalMilliseconds: Double) : Comparable<TimezoneOffset> , Serializable

Represents a time zone offset with millisecond precision. Usually minute is enough. Can be used along DateTimeTz to construct non universal, local times.

Link copied to clipboard
value class Year(val year: Int) : Comparable<Year> , Serializable

Represents a Year in a typed way.

Link copied to clipboard
value class YearMonth(internalPackedInfo: Int) : Serializable

Represents a couple of year and month.

Properties

Link copied to clipboard

TimeSpan representing this number as days or 86_400 seconds.

Returns the total number of days for this TimeSpan (86_400 seconds)

Link copied to clipboard

TimeSpan representing this number as hours or 3_600 seconds.

Returns the total number of hours for this TimeSpan (3_600 seconds)

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

Return true if Duration.NIL

Link copied to clipboard

TimeSpan representing this number as microseconds or 1 / 1_000_000 seconds.

Returns the total number of microseconds for this TimeSpan (1 / 1_000_000 seconds)

Link copied to clipboard

Returns the total number of microseconds for this TimeSpan (1 / 1_000_000 seconds) as Integer

Link copied to clipboard

Returns the total number of milliseconds as an Int

Link copied to clipboard

Returns the total number of milliseconds as a Long

Link copied to clipboard

TimeSpan representing this number as minutes or 60 seconds.

Returns the total number of minutes for this TimeSpan (60 seconds)

Link copied to clipboard

Months part of this MonthSpan as integer

Creates a MonthSpan representing these months.

Link copied to clipboard

TimeSpan representing this number as nanoseconds or 1 / 1_000_000_000 seconds.

Returns the total number of nanoseconds for this TimeSpan (1 / 1_000_000_000 seconds)

Link copied to clipboard

Returns the total number of nanoseconds for this TimeSpan (1 / 1_000_000_000 seconds) as Integer

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

TimeSpan representing this number as seconds.

Returns the total number of seconds for this TimeSpan

Link copied to clipboard
Link copied to clipboard

Total years of this MonthSpan as double (might contain decimals)

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

TimeSpan representing this number as weeks or 604_800 seconds.

Returns the total number of weeks for this TimeSpan (604_800 seconds)

Link copied to clipboard

Years part of this MonthSpan as integer

Creates a MonthSpan representing these years.

Functions

Link copied to clipboard

Sleeps the thread during the specified time. Spinlocks on JS

Link copied to clipboard
Link copied to clipboard
inline fun Duration.coalesce(block: () -> Duration): Duration
Link copied to clipboard
fun DateTime.convertRange(srcMin: DateTime, srcMax: DateTime, dstMin: DateTime, dstMax: DateTime): DateTime
fun TimeSpan.convertRange(srcMin: TimeSpan, srcMax: TimeSpan, dstMin: TimeSpan, dstMax: TimeSpan): TimeSpan
Link copied to clipboard
operator fun Duration.div(scale: Float): Duration
Link copied to clipboard
infix fun Duration.divFloat(other: Duration): Float
Link copied to clipboard
fun Year.first(dayOfWeek: DayOfWeek): DateTime
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Date.inThisWeek(dayOfWeek: DayOfWeek, locale: KlockLocale = KlockLocale.default): Date
Link copied to clipboard
Link copied to clipboard
inline fun TimeProvider.measure(block: () -> Unit): TimeSpan
Link copied to clipboard
inline fun measureTime(callback: () -> Unit): TimeSpan

Executes a callback and measure the time it takes to complete.

inline fun <T> measureTime(callback: () -> T, handleTime: (TimeSpan) -> Unit): T
Link copied to clipboard
inline fun <T> measureTimeWithResult(callback: () -> T): TimedResult<T>

Executes the callback measuring the time it takes to complete. Returns a TimedResult with the time and the return value of the callback.

Link copied to clipboard
Link copied to clipboard
operator fun Date.minus(time: DateTimeSpan): Date
operator fun Date.minus(time: MonthSpan): Date
operator fun Date.minus(time: Time): DateTime
operator fun Date.minus(time: TimeSpan): Date
operator fun Duration.minus(other: DateTimeSpan): DateTimeSpan
operator fun Duration.minus(other: MonthSpan): DateTimeSpan
Link copied to clipboard
Link copied to clipboard
fun DateFormat.parse(str: String, doAdjust: Boolean = true): DateTimeTz
fun TimeFormat.parse(str: String, doAdjust: Boolean = true): TimeSpan
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
operator fun Date.plus(time: DateTimeSpan): Date
operator fun Date.plus(time: MonthSpan): Date
operator fun Date.plus(time: Time): DateTime
operator fun Date.plus(time: TimeSpan): Date
operator fun Time.plus(span: TimeSpan): Time
operator fun Duration.plus(other: DateTimeSpan): DateTimeSpan
operator fun Duration.plus(other: MonthSpan): DateTimeSpan
Link copied to clipboard
operator fun Duration.rem(other: Duration): Duration
Link copied to clipboard
Link copied to clipboard
operator fun Duration.times(scale: Float): Duration
Link copied to clipboard
fun TimeSpan(milliseconds: Double): Duration
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Duration.toTimeString(components: Int = 3, addMilliseconds: Boolean = false): String

Formats this TimeSpan into something like 12:30:40.100.

Link copied to clipboard
infix fun Duration.umod(other: Duration): Duration
Link copied to clipboard
operator fun Duration.unaryPlus(): Duration
Link copied to clipboard

Generates a right-opened range between two DateTimes

Link copied to clipboard
Link copied to clipboard

Creates a YearMonth representing this year and this month.

Link copied to clipboard

Creates a YearMonth representing this year and this month.