Exemple #1
0
 private function ___fm___($f = null, $d = null)
 {
     $p = $this->_;
     $v = method_exists($this, $m = '__get_' . $p . '__') ? call_user_func([$this, $m]) : $this->___get___();
     switch ($this->prop_anon($p, 'type')) {
         case 'timestamp':
             return $v === null ? null : date(empty($f) ? \ebi\Conf::timestamp_format() : $f, (int) $v);
         case 'date':
             return $v === null ? null : date(empty($f) ? \ebi\Conf::date_format() : $f, (int) $v);
         case 'time':
             if ($v === null) {
                 return 0;
             }
             $h = floor($v / 3600);
             $i = floor(($v - $h * 3600) / 60);
             $s = floor($v - $h * 3600 - $i * 60);
             $m = str_replace(' ', '0', rtrim(str_replace('0', ' ', substr($v - $h * 3600 - $i * 60 - $s, 2, 12))));
             return ($h == 0 ? '' : $h . ':') . sprintf('%02d:%02d', $i, $s) . ($m == 0 ? '' : '.' . $m);
         case 'intdate':
             if ($v === null) {
                 return null;
             }
             return str_replace(['Y', 'm', 'd'], [substr($v, 0, -4), substr($v, -4, 2), substr($v, -2, 2)], empty($f) ? \ebi\Conf::date_format() : $f);
         case 'boolean':
             return $v ? isset($d) ? $d : 'true' : (empty($f) ? 'false' : $f);
     }
     return $v;
 }