Skip to content
The Missing Intervals of Twitter Util Time
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTORS.md
README.md
build.sbt

README.md

Twitter Intervals

Build Status codecov License GitHub stars

The missing intervals for the Twitter Util library. Currently supports test on intersection, and operations union and minus. Feel free to contribute.

Install

Available on Maven Central Repositories

libraryDependencies += "com.madewithtea" %% "twitterintervals" % "0.6.0" 

Example

import com.twitter.conversions.time._
import com.twitter.util.{Time, Duration}
import com.madewithtea.twitterintervals.Interval

val a = Interval(Time.Zero, Time.Zero + 1.day)
val b = Interval(Time.Zero + 1.hour, Time.Zero + 1.day)

// test on intersection
a intersects b shouldEqual true 

// union 
a union b shouldEqual Interval(Time.Zero, Time.Zero + 1.day)

// returning intersection intervals as Set of intervals
a minus b shouldEqual Set(Interval(Time.Zero, Time.Zero + 1.hour))

// can be empty
a minus a shouldEqual Set()

// using Twitter Time and Duration (conversions) with Intervals
a.duration shouldEqual 1.day
You can’t perform that action at this time.