<?php
"start" => "03/29/2016 12:00:00",
"end" => "03/29/2016 13:00:00"
),
"start" => "03/29/2016 12:30:00",
"end" => "03/29/2016 13:30:00"
),
"start" => "03/29/2016 13:00:00",
"end" => "03/29/2016 14:00:00"
),
"start" => "03/29/2016 13:30:00",
"end" => "03/29/2016 14:50:00"
),
"start" => "03/29/2016 14:00:00",
"end" => "03/29/2016 15:00:00"
),
"start" => "03/29/2016 14:30:00",
"end" => "03/29/2016 15:30:00"
),
"start" => "03/29/2016 15:00:00",
"end" => "03/29/2016 16:00:00"
),
"start" => "03/29/2016 15:30:00",
"end" => "03/29/2016 16:30:00"
),
"start" => "03/29/2016 16:00:00",
"end" => "03/29/2016 17:00:00"
)
);
"start" => "03/29/2016 08:00:00",
"end" => "03/29/2016 12:00:00"
),
"start" => "03/29/2016 15:30:00",
"end" => "03/29/2016 16:00:00"
),
"start" => "03/29/2016 13:30:00",
"end" => "03/29/2016 14:15:00"
)
);
foreach($internalEvents as $internalEvent) {
$internalEventStart = new DateTime($internalEvent['start']);
$internalEventEnd = new DateTime($internalEvent['end']);
$result = true;
echo "\nverifying " . $internalEventStart->format('Y-m-d H:i') . " - " . $internalEventEnd->format('Y-m-d H:i') . "\n";
foreach($externalEvents as $externalEvent) {
$externalEventStart = new DateTime($externalEvent['start']);
$externalEventEnd = new DateTime($externalEvent['end']);
// check if there are conflicts between internal and external events
if ($internalEventStart >= $externalEventStart && $internalEventStart <= $externalEventEnd) {
$result = false;
echo " problem 1: event is between busy time: " . "\n";
}
if ($internalEventStart >= $externalEventStart && $internalEventStart <= $externalEventEnd && $externalEventEnd <= $internalEventEnd) {
$result = false;
echo " problem 2: event starts during busy time: " . "\n";
}
if ($internalEventStart <= $externalEventStart && $externalEventStart <= $internalEventEnd && $internalEventEnd <= $externalEventEnd) {
$result = false;
echo " problem 3: event stops during busy time: " . "\n";
}
if (($internalEventStart <= $externalEventStart) && ($externalEventStart <= $externalEventEnd) && ($externalEventEnd <= $internalEventEnd)) {
$result = false;
echo " problem 4: event during busy time: " . "\n";
}
if (($internalEventStart <= $internalEventEnd) && ($internalEventEnd <= $externalEventStart) && ($externalEventStart <= $externalEventEnd)) {
$result = false;
echo " problem 5: event during busy time: " . "\n";
}
}
if($result) {
echo " result: OK\n";
} else {
echo " result: NOT OK \n";
}
}