Esempio n. 1
0
 public function setIgDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         $this->_set('ig_date', $fd->format('Y/m/d'));
         $this->_set('ig_date_mask', $fd->getMask());
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, true);
         $this->_set('ig_date', $dateTime->format('Y/m/d'));
         $this->_set('ig_date_mask', $dateTime->getMask());
     }
 }
 public function setExpeditionToDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         $this->_set('expedition_to_date', $fd->format('Y/m/d'));
         $this->_set('expedition_to_date_mask', $fd->getMask());
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, false);
         $this->_set('expedition_to_date', $dateTime->format('Y/m/d'));
         $this->_set('expedition_to_date_mask', $dateTime->getMask());
     }
 }
Esempio n. 3
0
 public function setGtuToDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         $this->_set('gtu_to_date', $fd->format('Y/m/d H:i:s'));
         $this->_set('gtu_to_date_mask', $fd->getMask());
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, false, true);
         if (is_array($fd)) {
             $dateTime->setMask(FuzzyDateTime::getMaskFromDate($fd));
         }
         $this->_set('gtu_to_date', $dateTime->format('Y/m/d H:i:s'));
         $this->_set('gtu_to_date_mask', $dateTime->getMask());
     }
 }
 public function setNotionDate($fd)
 {
     if ($fd instanceof FuzzyDateTime) {
         if ($this->getNotionDate() != $fd->getDateTimeMaskedAsArray()) {
             $this->_set('notion_date', $fd->format('Y/m/d'));
             $this->_set('notion_date_mask', $fd->getMask());
         }
     } else {
         $dateTime = new FuzzyDateTime($fd, 56, true);
         if ($this->getNotionDate() != $dateTime->getDateTimeMaskedAsArray()) {
             $this->_set('notion_date', $dateTime->format('Y/m/d'));
             $this->_set('notion_date_mask', $dateTime->getMask());
         }
     }
 }
 /**
  * Set DateTo field and mask if a fuzzyDateTime is passed
  * @param string|fuzzyDateTime $fd a fuzzyDateTime object or a string to pass to postgres
  * @return $this
  */
 public function setDateTo($fd)
 {
     if (is_string($fd)) {
         $this->_set('date_to', $fd);
     } elseif ($fd instanceof FuzzyDateTime) {
         $this->_set('date_to', $fd->format('Y/m/d'));
         $this->_set('date_to_mask', $fd->getMask());
     } else {
         if (empty($fd['day']) && empty($fd['month']) && empty($fd['year'])) {
             return;
         }
         $dateTime = new FuzzyDateTime($fd, 56, false);
         $this->_set('date_to', $dateTime->format('Y/m/d'));
         $this->_set('date_to_mask', $dateTime->getMask());
     }
     return $this;
 }
Esempio n. 6
0
 public function setParameters($data)
 {
     $param = '';
     $widget = self::getRequiredFieldForReport($data['name']);
     foreach ($widget as $field => $name) {
         if ($field == 'date_from' || $field == 'date_to') {
             $dateTime = new FuzzyDateTime($data[$field], 56, true);
             $param .= '"' . $field . '"=>"' . $dateTime->format('Y-m-d') . '",';
         } else {
             if (is_array($data[$field])) {
                 $param .= '"' . $field . '"=>"[' . implode(", ", $data[$field]) . ']",';
             } else {
                 $param .= '"' . $field . '"=>"' . $data[$field] . '",';
             }
         }
     }
     $this->_set('parameters', $param);
 }
$testArray['year'] = '1975';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), '', 'Date structure test ok');
$testArray['day'] = '24';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'month_missing', 'Date structure test ok');
$testArray['year'] = '';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'year_missing', 'Date structure test ok');
$testArray['year'] = '1975';
$testArray['month'] = '02';
$testArray['day'] = '';
$testArray['hour'] = '02';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'day_missing', 'Date structure test ok');
$testArray['year'] = '0001';
$testArray['month'] = '01';
$testArray['day'] = '01';
$fdt = new FuzzyDateTime($testArray);
$t->is($fdt->format('d/m/Y'), '01/01/0001', 'Date lower bound format ok');
$testArray = array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
$fdt = new FuzzyDateTime('2009/12/05');
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 12, 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
$fdt->setMask(48);
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 12, 'day' => 05, 'hour' => '', 'minute' => '', 'second' => '');
$fdt->setMask(56);
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 2);
$t->is('2009/02/28', FuzzyDateTime::getDateTimeStringFromArray($testArray, false), 'Date are nicelly completed with missing day in fev');
$testArray = array('year' => 2009, 'month' => 12);
$t->is('2009/12/31', FuzzyDateTime::getDateTimeStringFromArray($testArray, false), 'Date are nicelly completed  with missing day in decembre');
$testArray = array('year' => 2009, 'month' => 100);
$t->is('2038/12/31', FuzzyDateTime::getDateTimeStringFromArray($testArray, false), 'Default date is set from wrong dates');