今天遇到的问题是判断两段时间是否交叉。例如:
时间段A:start: 2015/02/03 end 2015/03/06
时间段B: start: 2015/03/02 end 2015/03/09
那么A和B是交叉的
判断的算法有很多种,最简单的方式为:
if (A.start < B.end && A.end > B.start) 则A和B有交叉
今天遇到的问题是判断两段时间是否交叉。例如:
时间段A:start: 2015/02/03 end 2015/03/06
时间段B: start: 2015/03/02 end 2015/03/09
那么A和B是交叉的
判断的算法有很多种,最简单的方式为:
if (A.start < B.end && A.end > B.start) 则A和B有交叉