public function contains(IDateTimeInterval $first, IDateTimeInterval $second) : bool { $firstStartDate = strtotime($first->getStartDate()); $firstEndDate = strtotime($first->getEndDate()); $secondStartDate = strtotime($second->getStartDate()); $secondEndDate = strtotime($second->getEndDate()); if ($secondStartDate >= $firstStartDate && $secondStartDate <= $firstEndDate && $secondEndDate >= $firstStartDate && $secondEndDate <= $firstEndDate) { return true; } else { return false; } }
public static function compareTo(IDateTimeInterval $first, IDateTimeInterval $second) : bool { $test = $first->getStartDate(); $firstStartDate = (new DateTime($first->getStartDate()))->getTimestamp(); $firstEndDate = (new DateTime($first->getEndDate()))->getTimestamp(); $secondStartDate = (new DateTime($second->getStartDate()))->getTimestamp(); $secondEndDate = (new DateTime($second->getEndDate()))->getTimestamp(); if ($firstEndDate < $secondStartDate) { return -1; } else { if ($firstStartDate > $secondEndDate) { return 1; } else { return 0; } } }