getDate() public method

public getDate ( $d = false, $fast = false ) : array
return array an array with date info.
Example #1
0
 public function testStringFormating()
 {
     $s = new TDateTimeStamp();
     $fmt = '\\d\\a\\t\\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \\R\\F\\C2822 r s t U w y Y z Z 2003';
     $s1 = date($fmt, 0);
     $s2 = $s->formatDate($fmt, 0);
     $this->assertEquals($s1, $s2);
     //, " date() 0 failed \n $s1 \n $s2");
     for ($i = 10; --$i > 0;) {
         $ts = 3600.0 * (rand() % 60000 + rand() % 60000) + rand() % 60000;
         $s1 = date($fmt, $ts);
         $s2 = $s->formatDate($fmt, $ts);
         //print "$s1 <br>$s2 <p>";
         $this->assertEquals($s1, $s2);
         $a1 = getdate($ts);
         $a2 = $s->getDate($ts, false);
         $this->assertEquals($a1, $a2);
     }
 }
Example #2
0
 /**
  * Gets the time stamp from string or integer.
  * @param string|int date to parse
  * @return array date info array
  */
 private function getDate($value)
 {
     $s = new TDateTimeStamp();
     if (is_numeric($value)) {
         return $s->getDate($value);
     } else {
         return $s->parseDate($value);
     }
 }
Example #3
0
 /**
  * Renders the drop down list date picker.
  */
 protected function renderDropDownListCalendar($writer)
 {
     if ($this->getMode() == TDatePickerMode::Basic) {
         $this->setMode(TDatePickerMode::ImageButton);
     }
     parent::addAttributesToRender($writer);
     $writer->removeAttribute('name');
     $writer->removeAttribute('type');
     $writer->addAttribute('id', $this->getClientID());
     if (strlen($class = $this->getCssClass()) > 0) {
         $writer->addAttribute('class', $class);
     }
     $writer->renderBeginTag('span');
     $s = new TDateTimeStamp();
     $date = $s->getDate($this->getTimeStampFromText());
     //$date = @getdate($this->getTimeStampFromText());
     $this->renderCalendarSelections($writer, $date);
     //render a hidden input field
     $writer->addAttribute('name', $this->getUniqueID());
     $writer->addAttribute('type', 'hidden');
     $writer->addAttribute('value', $this->getText());
     $writer->renderBeginTag('input');
     $writer->renderEndTag();
     $writer->renderEndTag();
 }
Example #4
0
 /**
  * Client-side Text property can only be updated after the OnLoad stage.
  * @param string text content for the textbox
  */
 public function setText($value)
 {
     if (parent::getText() === $value) {
         return;
     }
     parent::setText($value);
     if ($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData()) {
         $cb = $this->getPage()->getCallbackClient();
         $cb->setValue($this, $value);
         if ($this->getInputMode() == TDatePickerInputMode::DropDownList) {
             $s = new TDateTimeStamp();
             $date = $s->getDate($this->getTimeStampFromText());
             $id = $this->getClientID();
             $cb->select($id . TControl::CLIENT_ID_SEPARATOR . 'day', 'Value', $date['mday'], 'select');
             $cb->select($id . TControl::CLIENT_ID_SEPARATOR . 'month', 'Value', $date['mon'] - 1, 'select');
             $cb->select($id . TControl::CLIENT_ID_SEPARATOR . 'year', 'Value', $date['year'], 'select');
         }
     }
 }
Example #5
0
 protected function getDateTimeValue($container, $column, $record)
 {
     if (preg_match('/timestamp/i', $column->getDbType())) {
         $time = $container->findControl(self::DEFAULT_ID)->getTimestamp();
         $s = new TDateTimeStamp();
         $date = $s->getDate($time);
         $hour = $container->findControl('scaffold_time_hour')->getSelectedValue();
         $mins = $container->findControl('scaffold_time_min')->getSelectedValue();
         $secs = $container->findControl('scaffold_time_sec')->getSelectedValue();
         return $s->getTimeStamp($hour, $mins, $secs, $date['mon'], $date['mday'], $date['year']);
     } else {
         return parent::getDateTimeValue($container, $column, $record);
     }
 }