Klock

Klock Date and Time

Klock is a Date & Time library for Multiplatform Kotlin 1.3.

It is designed to be as allocation-free as possible using Kotlin inline classes, to be consistent and portable across targets since all the code is written in Common Kotlin, and to provide an API that is powerful, fun and easy to use.

https://github.com/korlibs/klock

Star

Build Status Maven Version

Table of contents:

Pages

  •  Dates - DateTime, Date, DayOfWeek, Month, Year, YearMonth, TimeZone...
  •  Spans - TimeSpan, MonthSpan, DateTimeSpan, DateTimeRange...
  •  Measure - measureTime, measureTimeWithResult & PerformanceCounter
  •  Format - Formatting, parsing and localization
  •  Testing - TimeProvider and testing

Using with gradle

Requires Gradle 7.1.1 (JVM 8~13) for building and Kotlin >=1.5.20 for running:

build.gradle.kts

val klockVersion = "2.2.0"

repositories {
    maven { url("https://dl.bintray.com/korlibs/korlibs") }
    jcenter()
}

// For multiplatform projects
kotlin {
    sourceSets {
        commonMain {
            dependencies {
                implementation("com.soywiz.korlibs.klock:klock:$klockVersion") 
            }
        }
    }
}

dependencies {
    // For JVM only
    implementation("com.soywiz.korlibs.klock:klock-jvm:$klockVersion") 
    // For Android only
    implementation("com.soywiz.korlibs.klock:klock-android:$klockVersion") 
    // For JS only
    implementation("com.soywiz.korlibs.klock:klock-js:$klockVersion") 
}