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

add overlap functionality to Timex.Interval #493

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

glassbead0
Copy link
Contributor

@glassbead0 glassbead0 commented Dec 10, 2018

Summary of changes

  • Find the overlap Interval between two intervals.
  • Return {:error, :no_overlap_interval} if intervals
    do not overlap, (including overlapping at one instant)

Checklist

  • New functions have typespecs, changed functions were updated
  • Same for documentation, including moduledocs
  • Tests were added or updated to cover changes
  • Commits were squashed into a single coherent commit

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 70.978% when pulling 8764c92 on glassbead0:add_overlap_to_interval into 5107429 on bitwalker:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 70.978% when pulling 8764c92 on glassbead0:add_overlap_to_interval into 5107429 on bitwalker:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 70.978% when pulling 8764c92 on glassbead0:add_overlap_to_interval into 5107429 on bitwalker:master.

@coveralls
Copy link

coveralls commented Dec 10, 2018

Coverage Status

Coverage increased (+0.4%) to 71.0% when pulling e10c8fa on glassbead0:add_overlap_to_interval into 5107429 on bitwalker:master.

@glassbead0 glassbead0 force-pushed the add_overlap_to_interval branch from 8764c92 to 1b5a171 Compare December 10, 2018 18:49
@@ -382,6 +382,71 @@ defmodule Timex.Interval do
def max(%__MODULE__{until: until, right_open: false}), do: until
def max(%__MODULE__{until: until}), do: Timex.shift(until, microseconds: -1)

@doc """
Returns an Interval representing the intersection between two intervals.
If the intervals do not overlap, reutrn {:error, :no_overlap_interval}.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misspelling reutrn


@doc """
When calculating overlap, if two intervals share a `from` (or `until`), the overlap
interval should have a bound matching the "inner" interval (eg: if either inteval has
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: inteval

* Find the overlap Interval between two intervals.
* Return {:error, :no_overlap_interval} if intervals
  do not overlap, (including overlapping at one instant)
@glassbead0 glassbead0 force-pushed the add_overlap_to_interval branch from 1b5a171 to e10c8fa Compare December 10, 2018 19:11
Returns an Interval representing the intersection between two intervals.
If the intervals do not overlap, return {:error, :no_overlap_interval}.
If the intervals overlap at a single instant (regardless of open/closed
bounds), also return {:error, :no_overlap_interval}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it should return 0 in the case of no overlap rather than an error? Two intervals not overlapping doesn't seem like an error to me.

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

Successfully merging this pull request may close these issues.

5 participants