Skip to content
Simple unit conversion library for Kotlin
Branch: master
Clone or download
Latest commit 45ede80 Jul 21, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
kobalt bump version Jul 21, 2016
src
.gitignore initial commit Mar 7, 2016
.travis.yml travis Mar 7, 2016
LICENSE license Mar 7, 2016
README.md bump version Jul 21, 2016
kobaltw fix kobaltw Jul 21, 2016
kobaltw.bat update kobalt Jul 21, 2016

README.md

Build Status Download

KtUnits

Simple unit conversion library for Kotlin.

Usage

Conversion

You can convert units easily:

fun foo() {
  val m = 100.minutes.toMilliseconds // magic
  println("100 minutes equal $m milliseconds")
}

Parameters

You can take a value as an argument without worrying about the units, and convert to the units you want when you use it.

fun wait(time: TimeValue) {
  Thread.sleep(time.toMilliseconds)
}

fun bar() {
  wait(5.seconds)
  wait(10.days)
}

Supported units

The library currently supports time (from nanoseconds to days) and memory (from bits to pebibytes).

Download

Just put this in your build.gradle or Build.kt. Replace <version> with the version shown in the badge at the top of this README.md.

dependencies {
  compile("me.sargunvohra.lib:ktunits:1.1.2")
}
You can’t perform that action at this time.