Checking if two time intervals overlap

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I have two time intervals i1 and i2, each defined by two values, begin and end (epoch time). I need to write a function returning a boolean value indicating whether the intervals overlap.



According to my understanding, an overlap can occur in four following cases:



enter image description here



while the last case (where the i2 is fully included within i1 is already covered by first two cases so can be dismissed.



The remaining three cases lead me to the following logic:



private static boolean isThereOverlap(Interval t1, Interval t2) 
t1.end.isAfter(t2.begin) && t1.end.isBefore(t2.end)


where:



t1 and t2 represent i1 and i2 accordingly.



I wonder whether there's a more concise way to identify the overlap or a
way to simplify the code?



EDIT1:



Including the Interval class which is utilizing java.time:



import java.time.Instant;

private class Interval
private Instant begin;
private Instant end;

private Interval(long begin, long end)
this.begin = Instant.ofEpochMilli(begin);
this.end = Instant.ofEpochMilli(end);











share|improve this question



















  • 1




    Is that Interval constructor really private? How then are you creating new instances of it? Please show your real actual code.
    – Simon Forsberg♦
    1 hour ago











  • @SimonForsberg Yes, it is. The Interval class and the isThereOverlap method, both reside in the same class.
    – Eugene S
    1 hour ago














up vote
4
down vote

favorite












I have two time intervals i1 and i2, each defined by two values, begin and end (epoch time). I need to write a function returning a boolean value indicating whether the intervals overlap.



According to my understanding, an overlap can occur in four following cases:



enter image description here



while the last case (where the i2 is fully included within i1 is already covered by first two cases so can be dismissed.



The remaining three cases lead me to the following logic:



private static boolean isThereOverlap(Interval t1, Interval t2) 
t1.end.isAfter(t2.begin) && t1.end.isBefore(t2.end)


where:



t1 and t2 represent i1 and i2 accordingly.



I wonder whether there's a more concise way to identify the overlap or a
way to simplify the code?



EDIT1:



Including the Interval class which is utilizing java.time:



import java.time.Instant;

private class Interval
private Instant begin;
private Instant end;

private Interval(long begin, long end)
this.begin = Instant.ofEpochMilli(begin);
this.end = Instant.ofEpochMilli(end);











share|improve this question



















  • 1




    Is that Interval constructor really private? How then are you creating new instances of it? Please show your real actual code.
    – Simon Forsberg♦
    1 hour ago











  • @SimonForsberg Yes, it is. The Interval class and the isThereOverlap method, both reside in the same class.
    – Eugene S
    1 hour ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











I have two time intervals i1 and i2, each defined by two values, begin and end (epoch time). I need to write a function returning a boolean value indicating whether the intervals overlap.



According to my understanding, an overlap can occur in four following cases:



enter image description here



while the last case (where the i2 is fully included within i1 is already covered by first two cases so can be dismissed.



The remaining three cases lead me to the following logic:



private static boolean isThereOverlap(Interval t1, Interval t2) 
t1.end.isAfter(t2.begin) && t1.end.isBefore(t2.end)


where:



t1 and t2 represent i1 and i2 accordingly.



I wonder whether there's a more concise way to identify the overlap or a
way to simplify the code?



EDIT1:



Including the Interval class which is utilizing java.time:



import java.time.Instant;

private class Interval
private Instant begin;
private Instant end;

private Interval(long begin, long end)
this.begin = Instant.ofEpochMilli(begin);
this.end = Instant.ofEpochMilli(end);











share|improve this question















I have two time intervals i1 and i2, each defined by two values, begin and end (epoch time). I need to write a function returning a boolean value indicating whether the intervals overlap.



According to my understanding, an overlap can occur in four following cases:



enter image description here



while the last case (where the i2 is fully included within i1 is already covered by first two cases so can be dismissed.



The remaining three cases lead me to the following logic:



private static boolean isThereOverlap(Interval t1, Interval t2) 
t1.end.isAfter(t2.begin) && t1.end.isBefore(t2.end)


where:



t1 and t2 represent i1 and i2 accordingly.



I wonder whether there's a more concise way to identify the overlap or a
way to simplify the code?



EDIT1:



Including the Interval class which is utilizing java.time:



import java.time.Instant;

private class Interval
private Instant begin;
private Instant end;

private Interval(long begin, long end)
this.begin = Instant.ofEpochMilli(begin);
this.end = Instant.ofEpochMilli(end);








java datetime interval






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 5 hours ago









Eugene S

1535




1535







  • 1




    Is that Interval constructor really private? How then are you creating new instances of it? Please show your real actual code.
    – Simon Forsberg♦
    1 hour ago











  • @SimonForsberg Yes, it is. The Interval class and the isThereOverlap method, both reside in the same class.
    – Eugene S
    1 hour ago












  • 1




    Is that Interval constructor really private? How then are you creating new instances of it? Please show your real actual code.
    – Simon Forsberg♦
    1 hour ago











  • @SimonForsberg Yes, it is. The Interval class and the isThereOverlap method, both reside in the same class.
    – Eugene S
    1 hour ago







1




1




Is that Interval constructor really private? How then are you creating new instances of it? Please show your real actual code.
– Simon Forsberg♦
1 hour ago





Is that Interval constructor really private? How then are you creating new instances of it? Please show your real actual code.
– Simon Forsberg♦
1 hour ago













@SimonForsberg Yes, it is. The Interval class and the isThereOverlap method, both reside in the same class.
– Eugene S
1 hour ago




@SimonForsberg Yes, it is. The Interval class and the isThereOverlap method, both reside in the same class.
– Eugene S
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
4
down vote













The code looks well presented, and it's clear how it maps to the problem statement.



The one thing that's not well defined is how we deal with exact equality of times. I'm assuming that intervals are always half-open (i.e. including the start time, but excluding the end time); it would be wise to add suitable comments to ensure that all readers agree on what's expected.




It's possible to simplify considerably, because in all cases we want (and none we don't), t1 ends after t2 begins and t2 ends after t1 begins, giving us a simpler expression:



t1.begin.isBefore(t2.end) && t2.begin.isBefore(t1.end)



If the Interval class is under your control, consider making this method a public instance method of that class. You might also want to check that the parameters are not null, if users might use that to indicate an empty interval:



if (t1 == null || t2 == null)
return false;


(this latter is an argument against using an instance method, as then the caller would need to check t1 isn't null).






share|improve this answer






















  • Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
    – Eugene S
    2 hours ago










  • @Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
    – Toby Speight
    1 min ago

















up vote
0
down vote













Your code uses an algorithm that directly tests for an overlap of time spans, but a simpler algorithm is to check for a non-overlap - to check for whether the time-spns are completely distinct. The spans are distinct if the first span starts after the other ends, or ends before the other one starts. This test is easy. The spans overlap if they are not distinct, so you can negate the logic for the isThereOverlap method.



private static boolean isThereOverlap(Interval t1, Interval t2) t1.begin.isAfter(t2.end));






share|improve this answer










New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








We are looking for answers that provide insightful observations about the code in the question. Answers that consist of independent solutions with no justification do not constitute a code review, and may be removed.









  • 4




    On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
    – rolfl♦
    3 hours ago






  • 2




    hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
    – elvaston5
    2 hours ago










  • Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
    – rolfl♦
    18 mins ago











Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f206710%2fchecking-if-two-time-intervals-overlap%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote













The code looks well presented, and it's clear how it maps to the problem statement.



The one thing that's not well defined is how we deal with exact equality of times. I'm assuming that intervals are always half-open (i.e. including the start time, but excluding the end time); it would be wise to add suitable comments to ensure that all readers agree on what's expected.




It's possible to simplify considerably, because in all cases we want (and none we don't), t1 ends after t2 begins and t2 ends after t1 begins, giving us a simpler expression:



t1.begin.isBefore(t2.end) && t2.begin.isBefore(t1.end)



If the Interval class is under your control, consider making this method a public instance method of that class. You might also want to check that the parameters are not null, if users might use that to indicate an empty interval:



if (t1 == null || t2 == null)
return false;


(this latter is an argument against using an instance method, as then the caller would need to check t1 isn't null).






share|improve this answer






















  • Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
    – Eugene S
    2 hours ago










  • @Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
    – Toby Speight
    1 min ago














up vote
4
down vote













The code looks well presented, and it's clear how it maps to the problem statement.



The one thing that's not well defined is how we deal with exact equality of times. I'm assuming that intervals are always half-open (i.e. including the start time, but excluding the end time); it would be wise to add suitable comments to ensure that all readers agree on what's expected.




It's possible to simplify considerably, because in all cases we want (and none we don't), t1 ends after t2 begins and t2 ends after t1 begins, giving us a simpler expression:



t1.begin.isBefore(t2.end) && t2.begin.isBefore(t1.end)



If the Interval class is under your control, consider making this method a public instance method of that class. You might also want to check that the parameters are not null, if users might use that to indicate an empty interval:



if (t1 == null || t2 == null)
return false;


(this latter is an argument against using an instance method, as then the caller would need to check t1 isn't null).






share|improve this answer






















  • Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
    – Eugene S
    2 hours ago










  • @Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
    – Toby Speight
    1 min ago












up vote
4
down vote










up vote
4
down vote









The code looks well presented, and it's clear how it maps to the problem statement.



The one thing that's not well defined is how we deal with exact equality of times. I'm assuming that intervals are always half-open (i.e. including the start time, but excluding the end time); it would be wise to add suitable comments to ensure that all readers agree on what's expected.




It's possible to simplify considerably, because in all cases we want (and none we don't), t1 ends after t2 begins and t2 ends after t1 begins, giving us a simpler expression:



t1.begin.isBefore(t2.end) && t2.begin.isBefore(t1.end)



If the Interval class is under your control, consider making this method a public instance method of that class. You might also want to check that the parameters are not null, if users might use that to indicate an empty interval:



if (t1 == null || t2 == null)
return false;


(this latter is an argument against using an instance method, as then the caller would need to check t1 isn't null).






share|improve this answer














The code looks well presented, and it's clear how it maps to the problem statement.



The one thing that's not well defined is how we deal with exact equality of times. I'm assuming that intervals are always half-open (i.e. including the start time, but excluding the end time); it would be wise to add suitable comments to ensure that all readers agree on what's expected.




It's possible to simplify considerably, because in all cases we want (and none we don't), t1 ends after t2 begins and t2 ends after t1 begins, giving us a simpler expression:



t1.begin.isBefore(t2.end) && t2.begin.isBefore(t1.end)



If the Interval class is under your control, consider making this method a public instance method of that class. You might also want to check that the parameters are not null, if users might use that to indicate an empty interval:



if (t1 == null || t2 == null)
return false;


(this latter is an argument against using an instance method, as then the caller would need to check t1 isn't null).







share|improve this answer














share|improve this answer



share|improve this answer








edited 3 hours ago

























answered 3 hours ago









Toby Speight

20.9k436103




20.9k436103











  • Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
    – Eugene S
    2 hours ago










  • @Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
    – Toby Speight
    1 min ago
















  • Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
    – Eugene S
    2 hours ago










  • @Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
    – Toby Speight
    1 min ago















Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
– Eugene S
2 hours ago




Thank you very much for your elaborate answer. Did you come up with this simplified expression from mere observation or is there some known approach to problems like this? Thanks again.
– Eugene S
2 hours ago












@Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
– Toby Speight
1 min ago




@Eugene, it's a problem I've seen before in slightly different form (and different programming language). I do find that these interval primitives confuse my brain when I'm writing them (but once I've implemented the primitives, then they make code much easier to work with).
– Toby Speight
1 min ago












up vote
0
down vote













Your code uses an algorithm that directly tests for an overlap of time spans, but a simpler algorithm is to check for a non-overlap - to check for whether the time-spns are completely distinct. The spans are distinct if the first span starts after the other ends, or ends before the other one starts. This test is easy. The spans overlap if they are not distinct, so you can negate the logic for the isThereOverlap method.



private static boolean isThereOverlap(Interval t1, Interval t2) t1.begin.isAfter(t2.end));






share|improve this answer










New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








We are looking for answers that provide insightful observations about the code in the question. Answers that consist of independent solutions with no justification do not constitute a code review, and may be removed.









  • 4




    On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
    – rolfl♦
    3 hours ago






  • 2




    hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
    – elvaston5
    2 hours ago










  • Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
    – rolfl♦
    18 mins ago















up vote
0
down vote













Your code uses an algorithm that directly tests for an overlap of time spans, but a simpler algorithm is to check for a non-overlap - to check for whether the time-spns are completely distinct. The spans are distinct if the first span starts after the other ends, or ends before the other one starts. This test is easy. The spans overlap if they are not distinct, so you can negate the logic for the isThereOverlap method.



private static boolean isThereOverlap(Interval t1, Interval t2) t1.begin.isAfter(t2.end));






share|improve this answer










New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








We are looking for answers that provide insightful observations about the code in the question. Answers that consist of independent solutions with no justification do not constitute a code review, and may be removed.









  • 4




    On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
    – rolfl♦
    3 hours ago






  • 2




    hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
    – elvaston5
    2 hours ago










  • Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
    – rolfl♦
    18 mins ago













up vote
0
down vote










up vote
0
down vote









Your code uses an algorithm that directly tests for an overlap of time spans, but a simpler algorithm is to check for a non-overlap - to check for whether the time-spns are completely distinct. The spans are distinct if the first span starts after the other ends, or ends before the other one starts. This test is easy. The spans overlap if they are not distinct, so you can negate the logic for the isThereOverlap method.



private static boolean isThereOverlap(Interval t1, Interval t2) t1.begin.isAfter(t2.end));






share|improve this answer










New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









Your code uses an algorithm that directly tests for an overlap of time spans, but a simpler algorithm is to check for a non-overlap - to check for whether the time-spns are completely distinct. The spans are distinct if the first span starts after the other ends, or ends before the other one starts. This test is easy. The spans overlap if they are not distinct, so you can negate the logic for the isThereOverlap method.



private static boolean isThereOverlap(Interval t1, Interval t2) t1.begin.isAfter(t2.end));







share|improve this answer










New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited 13 mins ago









rolfl♦

90.5k13189392




90.5k13189392






New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 4 hours ago









elvaston5

193




193




New contributor




elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






elvaston5 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



We are looking for answers that provide insightful observations about the code in the question. Answers that consist of independent solutions with no justification do not constitute a code review, and may be removed.




We are looking for answers that provide insightful observations about the code in the question. Answers that consist of independent solutions with no justification do not constitute a code review, and may be removed.








  • 4




    On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
    – rolfl♦
    3 hours ago






  • 2




    hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
    – elvaston5
    2 hours ago










  • Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
    – rolfl♦
    18 mins ago













  • 4




    On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
    – rolfl♦
    3 hours ago






  • 2




    hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
    – elvaston5
    2 hours ago










  • Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
    – rolfl♦
    18 mins ago








4




4




On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
– rolfl♦
3 hours ago




On Code Review we expect answers to review the code of the question - if your answer is an alternate solution to the same problem the OP faced, then your answer should explain the differences and why they are improvements. Unfortunately your answer does not do this. Further, the solution you provide has significant bugs - it reports some non-overlapping times as being overlapping times.
– rolfl♦
3 hours ago




2




2




hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
– elvaston5
2 hours ago




hi @rolfl ok, but i thought it was obvious as the question asked for a more concise alternative. I've also double checked the code for issues and can't see any obvious bugs, any pointers?
– elvaston5
2 hours ago












Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
– rolfl♦
18 mins ago





Argh... @elvaston5 - I hate when I am wrong. Your code does not have a bug. Regardless, we do expect code review answers to be more than just a "code drop" of an alternate solution. Your answer makes no reference back to the actual code in the OP's question, and only solves the same problem, differently (admittedly more concisely). Let me edit it a little, and try to show the difference, it may be subtle, but it is real.
– rolfl♦
18 mins ago


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f206710%2fchecking-if-two-time-intervals-overlap%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

One-line joke