Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
/ lib-duration Public archive

Internal classes to work with flow common duration model

License

Notifications You must be signed in to change notification settings

flowcommerce/lib-duration

Repository files navigation

Build Status

Scala library to make working with Flow's Common Duration object easier.

Installation

   "io.flow" %% "lib-duration" % "0.0.1"

Usage

    import io.flow.common.v0.models.Duration
    import io.flow.duration.InternalDuration


    val duration1 = InternalDuration(3, UnitOfTime.Month)
    val duration2 = InternalDuration(12, UnitOfTime.Hour)

    if (duration1.isShorterThan(duration2)) {
      println(s"Duration '${duration1.label}' is shorter than '${duration2.label}'")
    } else {
      println(s"Duration '${duration2.label}' is shorter than '${duration1.label}'")
    }

    val minDuration = Seq(duration1, duration2).min
    println(s"Shortest duration is: ${minDuration.label}")

Will produce:

Duration '12 hours' is shorter than '3 months'
Shortest duration is: 12 hours

Key Features

  • Sorting: InternalDuration extends Ordered making durations shortable
  • UnitOfTimeLabel provides for a pretty label

About

Internal classes to work with flow common duration model

Resources

License

Stars

Watchers

Forks

Packages

No packages published