https://github.com/jpzk/twitter-intervals
The Missing Intervals of Twitter Util Time
https://github.com/jpzk/twitter-intervals
date intervals time twitter utility
Last synced: 4 months ago
JSON representation
The Missing Intervals of Twitter Util Time
- Host: GitHub
- URL: https://github.com/jpzk/twitter-intervals
- Owner: jpzk
- Created: 2017-07-10T10:50:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-04T03:09:46.000Z (almost 8 years ago)
- Last Synced: 2023-07-01T13:05:06.260Z (almost 3 years ago)
- Topics: date, intervals, time, twitter, utility
- Language: Scala
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Twitter Intervals
[](https://travis-ci.org/jpzk/twitter-intervals) [](https://codecov.io/gh/jpzk/twitter-intervals) [](http://www.apache.org/licenses/LICENSE-2.0.txt) [](https://github.com/jpzk/twitter-intervals/stargazers)
The missing intervals for the [Twitter Util](https://github.com/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