17 $this->dateTimeFormat = strtr($this->dateTimeFormat,[
'[date]' => $this->dateFormat,
'[time]' => $this->timeFormat]);
21 return array_merge(parent::clientConfig(),[
22 'dateFormat' => $this->dateFormat,
23 'timeFormat' => $this->timeFormat,
24 'dateTimeFormat' => $this->dateTimeFormat,
25 'decimalPoint' => $this->decimalPoint,
26 'thousandsSeparator' => $this->thousandsSeparator,
27 'delimiter' => $this->delimiter
32 if(!$value)
return null;
34 return $value ? $value->format($this->dateFormat) : null;
42 if(\Rsi::nothing($value))
return $value;
44 return $value ? $value->format($this->timeFormat) : null;
52 if(\Rsi::nothing($value))
return $value;
54 return $value ? $value->format($this->dateTimeFormat) : null;
62 if(\Rsi::nothing($value))
return $value;
63 return number_format($value,0,$this->decimalPoint,$this->thousandsSeparator);
67 return (
int)str_replace($this->thousandsSeparator,
'',$value);
70 public function formatNumber($value,$decimals = 0,$trim = null,$zero = null){
71 if(\Rsi::nothing($value))
return $value;
72 $value = number_format($value,$decimals,$this->decimalPoint,$this->thousandsSeparator);
73 if($decimals && ($trim !== null))
74 while(($trim++ < $decimals) && !substr($value,-1)) $value = substr($value,0,-1);
75 if($zero !== null) $value = preg_replace(
'/' . preg_quote($this->decimalPoint,
'/') .
'0*$/',$zero,$value);
76 return rtrim($value,$this->decimalPoint);
80 return round(str_replace($this->decimalPoint,
'.',str_replace($this->thousandsSeparator,
'',$value)),$decimals);
84 return \Rsi\Str::transform((
new \NumberFormatter($locale,\NumberFormatter::SPELLOUT))->format($value),$format);
88 return \Rsi\Number::toRoman($value) ?: $value;
92 return \Rsi\Number::formatBytes($value,$decimals,$this->decimalPoint,$this->thousandsSeparator);
96 return \Rsi\Number::shorthandBytes($value);
static create($value, $format=null)
formatBytes($value, $decimals=1)
formatSpellOut($value, $locale=null, $format=null)
static create($value, $format=null)
formatNumber($value, $decimals=0, $trim=null, $zero=null)
static create($value, $format=null)
convertNumber($value, $decimals=0)