OnCallRotation - spansOverlap(ArrayList parent, ArrayList child, String timeZone)

Checks if the parent span and child spans overlap.

Table 1. Parameters
Name Type Description
parent ArrayList The parent spans to compare.
child ArrayList The child spans to compare.
timeZone String The name of the time zone.
Table 2. Returns
Type Description
Boolean Returns true if the parent and child spans overlap.
var onCall = new SNC.OnCallRotation();
 
// get a time range we are interested in
var timeZone = gs.getSession().getTimeZoneName();
var dateStart = new GlideDateTime();
var dateEnd = new GlideDateTime().addMonths(1);
 
// convert glidedatime to scheduledatetime because it is required
// by the function being called below
var scheduleStart = new GlideScheduleDateTime(dateStart);
var scheduleEnd =  new GlideScheduleDateTime(dateEnd);
scheduleStart.setTimeZone(timeZone);
scheduleEnd.setTimeZone(timeZone);
 
// calculate rotation items based on the date and time given
// for all the groups the currently logged in user is a member of
gs.include("OnCallRotationPersonal");
var rotation = new OnCallRotationPersonal();
var myGroups = gs.getUser().getMyGroups();
var groupIter = myGroups.iterator();
 
while(groupIter.hasNext()){
	var rotaItems = rotation.onCallDuringPeriod(groupIter.next(), scheduleStart, scheduleEnd);
 
	// loop through rotation schedules
	for (var i = 0; i < rotaItems.length - 1; i++) {
		var parentItem = rotaItems[i];
		var nextItem = rotaItems[i + 1];
 
		// check if previous and next time spans overlap
		var overlaps = onCall.spansOverlap(parentItem.getTimeSpans(), nextItem.getTimeSpans(), 
			gs.getSession().getTimeZoneName());
	}
}