19 declare(strict_types=1);
38 $this->
lng = $DIC->language();
39 $this->
user = $DIC->user();
47 $result instanceof Result\StringResult => $this->
formatString($result),
48 default => $result->getValue()
54 return $result->getValue();
59 $calculated_timestamp = (
int) $result->getValue();
60 switch ($result->getFromOperator()) {
61 case Operators::SUBTRACTION:
62 $presentation =
function ($value, $factor, $unit) {
65 ) .
' ' . $this->
lng->txt($unit);
69 $value = (
int) $calculated_timestamp;
77 $value = $presentation($value, 1,
'seconds');
80 $value = $presentation($value, 60,
'minutes');
82 case $value < 24 * 3600:
83 $value = $presentation($value, 3600,
'hours');
86 $value = $presentation($value, 24 * 3600,
'days');
89 return $prefix . $value;
90 case Operators::ADDITION:
91 case Operators::MULTIPLICATION:
92 case Operators::DIVISION:
93 case Operators::POWER:
96 switch ($result->getFromFunction()) {
99 case Functions::AVERAGE:
100 return date($this->
user->getDateFormat()->toString(), $calculated_timestamp);
110 $value = (
int) $result->getValue();
111 if (abs($value) >= self::SCIENTIFIC_NOTATION_UPPER) {
112 return sprintf(
"%e", $value);
114 if (abs($value) <= self::SCIENTIFIC_NOTATION_LOWER && $value != 0) {
115 return sprintf(
"%e", $value);
119 if (abs($value) >= 1000) {
120 if (is_float($value)) {
121 $decimals = self::N_DECIMALS;
125 return number_format(
128 $this->
lng->txt(
'lang_sep_decimal'),
129 $this->
lng->txt(
'lang_sep_thousand')
133 return (
string) $value;