Ejemplo n.º 1
0
 public function migrateDate($day, $month, $year, $weekday, $comment = null)
 {
     //insert into new data
     $newDate = new Date();
     $newDate->setDay($day);
     $newDate->setMonth($month);
     $newDate->setYear($year);
     $newDate->setWeekday($weekday);
     $newDate->setComment($this->normalize($comment));
     $this->getDBManager()->persist($newDate);
     $this->getDBManager()->flush();
     return $newDate->getId();
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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;
 }