GithubHelp home page GithubHelp logo

kotlin-datatypes's Introduction

kotlin-datatypes

A collection of Kotlin Multiplatform libraries to represent complex data types.

Check out the docs for details!

What's available?

Bitrate for reading from and converting to units of digital data transfer, for example Mebibits per second to Gibibits per second.

Capacity for reading from and converting to digital storage types, for example Megabytes to Gigabytes.

Percentage for reading from and converting to the most common percentage formats, for example 1.0f to 100.

Temperature for reading from and converting to Celsius, Fahrenheit, Kelvin, Rankine and Réaumur.

Setup

kotlin {
    sourceSets {
        commonMain.dependencies {
            val datatypesVersion = "1.3.2"

            // Add dependency on Bitrate
            implementation("io.github.boswelja.datatypes:bitrate:$datatypesVersion")

            // Add dependency on Capacity
            implementation("io.github.boswelja.datatypes:capacity:$datatypesVersion")

            // Add dependency on Percentage
            implementation("io.github.boswelja.datatypes:percentage:$datatypesVersion")

            // Add dependency on Temperature
            implementation("io.github.boswelja.datatypes:temperature:$datatypesVersion")
        }
    }
}

Platform support

All libraries currently support Android, iOS, macOS, tvOS, watchOS, JVM, Linux, Windows and WASM-JS. For now, they are only accessible from Kotlin Multiplatform projects. We are exploring publishing native libraries for use directly in other languages.

Why?

I was tired of having to write functions that convert between units, like hours to seconds (5 / 60.0 / 60.0). After a bit of looking around, I found out Kotlin had a built-in Duration that could handle time conversions! 5.hours.inWholeSeconds is much more readable.

After discovering Duration, I thought "well why not do the same for units of digital storage". And then I got carried away, so here we are with a repository full of many different types.

kotlin-datatypes's People

Contributors

boswelja avatar dependabot[bot] avatar

Stargazers

Edric Chan avatar

Watchers

 avatar  avatar

kotlin-datatypes's Issues

Add Imperial and Metric units

Distances shouldn't be terribly difficult, but good luck with units of mass.

What even is a "cup" and why is the weight different depending on the thing it holds?

See Wikivoyage for equivalents and conversion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.