Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible improvement: add the ability to exclude the end of the interval when splitting by period #133

Open
vladimir-gavrilenko opened this issue Feb 25, 2019 · 0 comments

Comments

@vladimir-gavrilenko
Copy link

Hi!

According to #83 and #79 the end of the interval is included when splitting by period. I guess there should be a way in this library to cover not only the inclusive case but also the exclusive.

To cover the exclusive case I suggest one of the following:

  1. Add until to RichReadableInstant.scala
// RichReadableInstant.scala
// ...
def until(other: ReadableInstant): Interval = to(other).withEnd(other.toInstant.minus(1L))
// ...

// User's code
val inclusive = start to stop by 5.minutes
val exclusive = start until stop by 5.minutes

The problem here is that interval contains interval.end is false.

  1. Add exclusiveBy to RichInterval.scala
// RichInterval.scala
// ...
def exclusiveBy(period: ReadablePeriod): List[DateTime] = by(period).dropRight(1)
// ...

// User's code
val inclusive = start to stop by 5.minutes
val exclusive = start to stop exclusiveBy 5.minutes

I will be glad to create a PR with one of the proposed or any other solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant