klock

Consistent and portable date and time utilities for multiplatform Kotlin

License

License

Categories

Categories

Data
GroupId

GroupId

com.soywiz.korlibs.klock
ArtifactId

ArtifactId

klock-metadata
Last Version

Last Version

2.0.7
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

klock
Consistent and portable date and time utilities for multiplatform Kotlin
Project URL

Project URL

https://github.com/korlibs/klock
Source Code Management

Source Code Management

https://github.com/korlibs/klock

Download klock-metadata

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Klock

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.

Build Status Maven Version Discord

Support klock

If you like klock, or want your company logo here, please consider becoming a sponsor ★,
in addition to ensure the continuity of the project, you will get exclusive content.

Full Documentation: https://korlibs.soywiz.com/klock/

Some samples:

val now = DateTime.now()
val duration = 1.seconds
val later = now + 1.months + duration
val is2018Leap = Year(2018).isLeap
val daysInCurrentMonth = now.yearMonth.days
val daysInNextMonth = (now.yearMonth + 1.months).days

Usage with gradle:

(Compiled and tested with Gradle 5.4.1, JVM 12.0.1 and Kotlin 1.3.31). Starting with Klock 2.0.7, the library is available at mavenCentral. Versions from 2.0.6 down to 1.4.0 are available at jcenter.

def klockVersion = "2.0.7"

repositories {
    mavenCentral()
    //Versions older than 2.0.7 are available on jcenter()
}

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                implementation "com.soywiz.korlibs.klock:klock:$klockVersion" // Common 
            }
        }
    }
}

settings.gradle

enableFeaturePreview('GRADLE_METADATA')

Use with Kotlin-JVM

def klockVersion = "2.0.7"

repositories {
    mavenCentral()
    //Versions older than 2.0.7 are available on jcenter()
}

dependencies {
    implementation "com.soywiz.korlibs.klock:klock-jvm:$klockVersion"
}

Versions

Klock Kotlin Gradle Metadata JVM version
2.0.0-alpha 1.4.10 1.0 1.8
1.12.0 1.4.0 1.0 1.8
1.11.14 1.3.72 1.0 1.8
1.8.4 1.3.61 1.0 1.8
1.8.0 1.3.60 1.0 1.8
1.7.0 1.3.50 1.0 1.6
1.6.0 1.3.50 1.0 1.6
1.5.0 1.3.40 1.0 1.6
1.4.0 1.3.21 1.0 1.6

Testing & Kotest

Kotest is a flexible and comprehensive testing tool for Kotlin with multiplatform support. It supports Klock adding additional matchers. For a full list of Klock Kotest matchers, check this link: https://github.com/kotest/kotest/blob/master/doc/matchers.md

And you can find a sample here: https://github.com/kotest/kotest/tree/master/kotest-assertions/kotest-assertions-klock

com.soywiz.korlibs.klock
Kotlin cORoutine Libraries for fullstack development - https://bintray.com/korlibs/korlibs - https://github.com/korlibs

Versions

Version
2.0.7