function findShallowIntersectingRange(date1, date2) {
  const thisRange = date1.toRange();
  const otherRange = date2.toRange();
  // Start with infinite start and end dates
  let start = null;
  let end = null;
  // This start date exists
  if (thisRange.start) {
    // Use this definite start date if other start date is infinite
    if (!otherRange.start) start = thisRange.start;
    else
      // Otherwise, use the earliest start date
      start =
        thisRange.start < otherRange.start ? thisRange.start : otherRange.start;
    // Other start date exists
  } else if (otherRange.start) {
    // Use other definite start date as this one is infinite
    start = otherRange.start;
  }
  // Assign end date to this one if it is valid
  if (thisRange.end && (!start || thisRange.end >= start)) {
    end = thisRange.end;
  }
  // Assign end date to other one if it is valid and before this one
  if (otherRange.end && (!start || otherRange.end >= start)) {
    if (!end || otherRange.end < end) end = otherRange.end;
  }
  // Return calculated range
  return { start, end };
}
function findShallowIntersectingRange(date1, date2) {
  const thisRange = date1.toRange();
  const otherRange = date2.toRange();
  
  let start = null;
  let end = null;
  
  if (thisRange.start) {
    
    if (!otherRange.start) start = thisRange.start;
    else
      
      start =
        thisRange.start < otherRange.start ? thisRange.start : otherRange.start;
    
  } else if (otherRange.start) {
    
    start = otherRange.start;
  }
  
  if (thisRange.end && (!start || thisRange.end >= start)) {
    end = thisRange.end;
  }
  
  if (otherRange.end && (!start || otherRange.end >= start)) {
    if (!end || otherRange.end < end) end = otherRange.end;
  }
  
  return { start, end };
}
function findShallowIntersectingRange ( date1 , date2 ) { const thisRange = date1 . toRange ( ) ; const otherRange = date2 . toRange ( ) ; // Start with infinite start and end dates let start = null ; let end = null ; // This start date exists if ( thisRange . start ) { // Use this definite start date if other start date is infinite if ( ! otherRange . start ) start = thisRange . start ; else // Otherwise, use the earliest start date start = thisRange . start < otherRange . start ? thisRange . start : otherRange . start ; // Other start date exists } else if ( otherRange . start ) { // Use other definite start date as this one is infinite start = otherRange . start ; } // Assign end date to this one if it is valid if ( thisRange . end && ( ! start || thisRange . end >= start ) ) { end = thisRange . end ; } // Assign end date to other one if it is valid and before this one if ( otherRange . end && ( ! start || otherRange . end >= start ) ) { if ( ! end || otherRange . end < end ) end = otherRange . end ; } // Return calculated range return { start , end } ; }
Returns a date range that intersects two date info objects NOTE: This is a shallow calculation (does not take patterns into account), so this method should only really be called for special conditions where absolute accuracy is not necessarily needed
Returns a date range that intersects two date info objects NOTE : This is a shallow calculation ( does not take patterns into account ) so this method should only really be called for special conditions where absolute accuracy is not necessarily needed