Exemplo n.º 1
0
 function testCDate()
 {
     $dt = Raxan::cDate('1/1/2009');
     $this->ok($dt instanceof RaxanDateTime, 'Instance of RaxanDateTime');
     $this->compare($dt->format('d/M/Y'), '01/Jan/2009', 'Valid Date format');
 }
Exemplo n.º 2
0
 /**
  * Returns formated date value
  * @param string $key Key name or input value (direct input must be enabled)
  * @param string $format Date format
  * @return string If input is an array then an array of formated date values is returned
  */
 public function formatDate($key, $format = null)
 {
     if ($format === null) {
         $format = 'iso';
     }
     $noTrans = false;
     switch ($format) {
         case 'iso':
         case 'mysql':
             $format = 'Y-m-d';
             $noTrans = true;
             break;
         case 'mssql':
             $format = 'm/d/Y';
             $noTrans = true;
             break;
         case 'short':
             $format = Raxan::locale('date.short');
             break;
         case 'long':
             $format = Raxan::locale('date.long');
             break;
     }
     if (!isset($this->_date)) {
         $this->_date = Raxan::cDate();
     }
     $v = $this->value($key);
     if (!($isa = is_array($v))) {
         try {
             $v = $v ? $this->_date->format($format, $v, $noTrans) : '';
         } catch (Exception $e) {
             $v = '';
         }
     } else {
         foreach ($v as $k => $b) {
             try {
                 $b = $b ? $this->_date->format($format, $b, $noTrans) : '';
             } catch (Exception $e) {
                 $b = '';
             }
             $v[$k] = $b;
         }
     }
     return $v;
 }