public static DateRange StartingOn(System.DateTime startInclusive) { var dr = new DateRange(startInclusive); return dr; }
// /// <summary> /// Gets the mathematical intersection of 2 date ranges /// </summary> /// <param name="dr">The second date range used for interception</param> /// <returns>A DateRange which contains the intersected range, null if 2 Ranges do not intercept</returns> public DateRange IntersectWith(DateRange dr) { var startDate = StartInclusiveDate < dr.StartInclusiveDate ? dr.StartInclusiveDate : StartInclusiveDate; var endDate = EndInclusiveDate < dr.EndInclusiveDate ? EndInclusiveDate : dr.EndInclusiveDate; if (startDate > endDate) return null; return new DateRange(startDate, endDate); }
public static DateRange For(System.DateTime startInclusive, System.DateTime endInclusive) { if (endInclusive < startInclusive) throw new ArgumentException("End is before start."); var dr = new DateRange(); dr.m_startInclusiveDate = startInclusive; dr.m_endInclusiveDate = endInclusive; return dr; }
public bool IntersectsWith(DateRange dr) { return IntersectsWith(dr.StartInclusiveDate, dr.EndInclusiveDate); }