/** * @param DateTime $startDate * @param DateTime $endDate * @return TimeSpan */ public static function asInterval(DateTime $startDate, DateTime $endDate) { $newThis = new TimeSpan(); $newThis->checkStartEndDateAndSetInterval($startDate, $endDate); $newThis->setStartDate($startDate); $newThis->setEndDate($endDate); return $newThis; }