private function mergeDateObjects(\UR\DB\NewBundle\Entity\Date $dataMasterDate, \UR\DB\NewBundle\Entity\Date $toBeDeletedDate) { //merge date! //and mind 0.0.1800 and similar dates! //if one date is "genauer" als the other, use it! //btw. ignore comments just merge them if necessary! $dataMasterDate->setDay($this->mergeStrings($dataMasterDate->getDay(), $toBeDeletedDate->getDay())); $dataMasterDate->setMonth($this->mergeStrings($dataMasterDate->getMonth(), $toBeDeletedDate->getMonth())); $dataMasterDate->setYear($this->mergeStrings($dataMasterDate->getYear(), $toBeDeletedDate->getYear())); $dataMasterDate->setWeekday($this->mergeStrings($dataMasterDate->getWeekday(), $toBeDeletedDate->getWeekday())); $dataMasterDate->setComment($this->mergeComment($dataMasterDate->getComment(), $toBeDeletedDate->getComment())); //@TODO: Before/ After booleans? They are not getting merged right now //remove toBeDeletedDate $this->getDBManager()->remove($toBeDeletedDate); }
public function matchingDateObj(\UR\DB\NewBundle\Entity\Date $dateOne, \UR\DB\NewBundle\Entity\Date $dateTwo, $allowLessInformation = false) { $this->LOGGER->debug("Comparing '" . $dateOne . "' with '" . $dateTwo . "'"); if (!$allowLessInformation) { if ($dateOne->getDay() != $dateTwo->getDay()) { return false; } if ($dateOne->getMonth() != $dateTwo->getMonth()) { return false; } if ($dateOne->getYear() != $dateTwo->getYear()) { return false; } } else { if ($dateOne->getDay() == null || $dateTwo->getDay() == null) { return true; } else { if ($dateOne->getDay() != $dateTwo->getDay()) { return false; } } if ($dateOne->getMonth() == null || $dateTwo->getMonth() == null) { return true; } else { if ($dateOne->getMonth() != $dateTwo->getMonth()) { return false; } } if ($dateOne->getYear() == null || $dateTwo->getYear() == null) { return true; } else { if ($dateOne->getYear() != $dateTwo->getYear()) { return false; } } } if (!$this->compareStrings($dateOne->getWeekday(), $dateTwo->getWeekday(), $allowLessInformation)) { return false; } if (!$this->compareStrings($dateOne->getBeforeDate(), $dateTwo->getBeforeDate(), $allowLessInformation)) { return false; } if (!$this->compareStrings($dateOne->getAfterDate(), $dateTwo->getAfterDate(), $allowLessInformation)) { return false; } $this->LOGGER->debug("Dates are matching"); return true; }