33 $datum = sprintf(
"%02d.%02d.%04d", $date[
"mday"],$date[
"mon"],$date[
"year"]);
48 $date=
"";
$y=
""; $m=
"";
$d=
"";
50 if (ereg(
"([0-9]{1,2}).([0-9]{1,2}).([0-9]{2,4})",$AInputDate,$p))
57 if ((
$d>0 &&
$d<32) && ($m>0 && $m<13) && (strlen(
$y)!=3))
59 if (strlen(
$d) == 1)
$d =
"0".$d;
60 if (strlen($m) == 1) $m =
"0".$m;
64 if (
$y>=70)
$y =
$y + 1900;
69 checkdate($m,
$d,
$y);
74 $uhrzeit = substr($AInputDate, -8);
77 if (ereg(
"([0-9]{2}):([0-9]{2}):([0-9]{2})",$AInputDate,$p))
83 if (($h>-1 && $h<24) && ($min>-1 && $min<60) && ($s>-1 && $s<60))
86 $date = sprintf(
"%04d-%02d-%02d %02d:%02d:%02d",
$y,$m,
$d,$h,$min,$s);
93 $date = sprintf(
"%04d-%02d-%02d %02d:%02d:%02d",
$y,$m,
$d,$zeit[
"hours"],$zeit[
"minutes"],$zeit[
"seconds"]);
110 substr($ADatumSQL, 5, 2).
111 substr($ADatumSQL, 8, 2).
112 substr($ADatumSQL, 11, 2).
113 substr($ADatumSQL, 14, 2).
114 substr($ADatumSQL, 17, 2);
126 substr($ADatum, 3, 2).
127 substr($ADatum, 0, 2).
128 substr($ADatum, 11, 2).
129 substr($ADatum, 14, 2).
130 substr($ADatum, 17, 2);
142 return sprintf(
"%02d.%02d.%04d",substr(
$t, 8, 2),substr(
$t, 5, 2),substr(
$t, 0, 4));
152 return sprintf(
"%02d.%02d.%04d",substr(
$t, 6, 2),substr(
$t, 4, 2),substr(
$t, 0, 4));
162 return sprintf(
"%02d.%02d.%04d %02d:%02d:%02d",substr(
$t, 6, 2),substr(
$t, 4, 2),substr(
$t, 0, 4),substr(
$t, 8, 2),substr(
$t, 10, 2),substr(
$t, 12, 2));
172 return sprintf(
"%04d-%02d-%02d",substr(
$t, 0, 4),substr(
$t, 4, 2),substr(
$t, 6, 2));
184 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $aTimestamp, $matches))
186 $date =
"$matches[1]-$matches[2]-$matches[3] $matches[4]:$matches[5]:$matches[6]";
201 if ($ADate1 > $ADate2)
216 return doubleval(ereg_replace (
",",
".",$var));
225 $num_args = func_num_args();
227 $geld = func_get_arg(0);
231 $test = intval($geld);
237 return number_format($geld,2,
",",
".").
" €";
247 $num_args = func_num_args();
249 $prozent = func_get_arg(0);
253 $test = intval($prozent);
259 return number_format($prozent,2,
",",
".").
"%";
268 return round($value * 100) / 100;
288 public static function fmtDateTime($a_str,$a_dateformat,$a_timeformat,$a_mode =
"datetime", $a_relative = TRUE)
291 if ($a_dateformat ==
"")
293 $a_dateformat =
"Y-m-d";
297 if ($a_timeformat ==
"")
299 $a_timeformat =
"H:i:s";
303 if ($a_str ==
'0000-00-00 00:00:00')
306 return $lng->txt(
'no_date');
310 $d = substr($a_str,8,2);
311 $m = substr($a_str,5,2);
312 $y = substr($a_str,0,4);
313 $h = substr($a_str,11,2);
314 $i = substr($a_str,14,2);
315 $s = substr($a_str,17,4);
319 (
$y == 1970 and ($m < 1 or
$d < 1)))
327 if ($a_mode ==
"time")
329 return date($a_timeformat,mktime($h,$i,$s,1,1,1999));
335 $minuteswest = gettimeofday(
false);
336 $minuteswest = $minuteswest[
'minuteswest'];
337 $today = $now - $now % (24 * 60 * 60) + $minuteswest * 60;
345 $date = ($isToday) ? $lng->txt(
'today') :
346 (($isYesterday) ? $lng->txt(
'yesterday') :
347 (($isTomorrow) ? $lng->txt(
'tomorrow') :
348 date($a_dateformat,mktime($h,$i,$s,$m,
$d,
$y))))
353 $date = date($a_dateformat,mktime($h,$i,$s,$m,
$d,
$y));
356 return ($a_mode ==
"date") ? $date : $date.
' '.date($a_timeformat,mktime($h,$i,$s,$m,
$d,
$y));
373 function fmtFloat($a_float, $a_decimals=0, $a_dec_point = null, $a_thousands_sep = null, $a_suppress_dot_zero=
false)
378 if ($a_dec_point == null)
380 $a_dec_point = $lng->txt(
'lang_sep_decimal');
385 if ($a_dec_point ==
'-lang_sep_decimal-')
390 if ($a_thousands_sep == null)
392 $a_thousands_sep = $lng->txt(
'lang_sep_thousand');
397 if ($a_thousands_sep ==
'-lang_sep_thousand-')
399 $a_thousands_sep =
",";
402 $txt = number_format($a_float, $a_decimals, $a_dec_point, $a_thousands_sep);
405 if (($a_suppress_dot_zero == 0 || $a_decimal == 0) &&
406 substr($txt,-2) == $a_dec_point.
'0')
408 $txt = substr($txt, 0, strlen($txt) - 2);
410 if ($a_float == 0 and $txt ==
"")
419 if (strlen($a_unix_timestamp) == 0)
421 return strftime(
"%Y-%m-%d %H:%M:%S");
425 return strftime(
"%Y-%m-%d %H:%M:%S", $a_unix_timestamp);
440 function formatDate($a_date,$a_mode =
"datetime", $a_omit_seconds =
false, $a_relative = TRUE)
445 if ($a_date ==
"0000-00-00 00:00:00")
447 return $lng->txt(
"no_date");
450 $dateformat = $lng->txt(
"lang_dateformat");
451 if ($a_omit_seconds && ($lng->txt(
"lang_timeformat_no_sec") !=
"-lang_timeformat_no_sec-"))
453 $timeformat = $lng->txt(
"lang_timeformat_no_sec");
457 $timeformat = $lng->txt(
"lang_timeformat");
460 if ($dateformat ==
"-lang_dateformat-")
465 if ($timeformat ==
"-lang_timeformat-")
477 $format = $lng->txt(
'lang_dateformat');
481 $format .= (
' '.$lng->txt(
'lang_timeformat_no_sec'));
483 return date($format,
$ut);
495 $r = $a_ts2 - $a_ts1;
497 $dd = floor($r/86400);
504 $hh = floor($r/3600);
522 return $hh.
":".$mm.
":".$ss;
533 $arrDT = explode(
" ", $a_datetime);
534 $arrD = explode(
"-", $arrDT[0]);
535 $arrT = explode(
":", $arrDT[1]);
537 return mktime($arrT[0], $arrT[1], $arrT[2], $arrD[1], $arrD[2], $arrD[0]);
551 $seconds = $seconds ? $seconds : 0;
555 $days = floor($seconds / 86400);
556 $rest = $seconds % 86400;
558 $hours = floor(
$rest / 3600);
561 $minutes = floor(
$rest / 60);
562 $seconds =
$rest % 60;
566 $message = $days .
' '. $lng->txt(
'days');
574 $message .= ($hours .
' '. $lng->txt(
'hours'));
582 $message .= ($minutes .
' '. $lng->txt(
'minutes'));
584 if($force_with_seconds && $seconds)
590 $message .= ($seconds .
' '. $lng->txt(
'seconds'));
592 if(!$days and !$hours and !$minutes)
594 return $seconds .
' '. $lng->txt(
'seconds');
612 $seconds = $seconds ? $seconds : 0;
616 $days = floor($seconds / 86400);
617 $rest = $seconds % 86400;
619 $hours = floor(
$rest / 3600);
622 $minutes = floor(
$rest / 60);
625 return sprintf(
"%02d:%02d:%02d:%02d",$days,$hours,$minutes,
$rest);
638 $language = $ilias->getSetting(
"language");
639 $money_locale = $language.
'_'.strtoupper($language);
644 setlocale(LC_MONETARY, $money_locale);
645 return $float_number;
672 public static function formatFloat($size, $a_decimals, $a_suppress_dot_zero=
false, $a_mode =
'short', $a_lng = null)
675 if ($a_lng == null) {
678 return self::fmtFloat($size, $a_decimals, $a_lng->txt(
'lang_sep_decimal'), $a_lng->txt(
'lang_sep_thousand', $a_suppress_dot_zero),
true).
' '.$a_lng->txt($scaled_unit);
696 public static function formatSize($size, $a_mode =
'short', $a_lng = null)
699 if ($a_lng == null) {
703 require_once
'classes/class.ilFormat.php';
711 if ($size >= $mag * $mag * $mag)
713 $scaled_size = $size/$mag/$mag/$mag;
714 $scaled_unit =
'lang_size_gb';
716 else if ($size >= $mag * $mag)
718 $scaled_size = $size/$mag/$mag;
719 $scaled_unit =
'lang_size_mb';
721 else if ($size >= $mag)
723 $scaled_size = $size/$mag;
724 $scaled_unit =
'lang_size_kb';
728 $scaled_size = $size;
729 $scaled_unit =
'lang_size_bytes';
732 $result =
self::fmtFloat($scaled_size,($scaled_unit ==
'lang_size_bytes') ? 0:1, $a_lng->txt(
'lang_sep_decimal'), $a_lng->txt(
'lang_sep_thousand'),
true).
' '.$a_lng->txt($scaled_unit);
733 if ($a_mode ==
'long' && $size > $mag)
736 self::fmtFloat($size,0,$a_lng->txt(
'lang_sep_decimal'),$a_lng->txt(
'lang_sep_thousand')).
737 ' '.$a_lng->txt(
'lang_size_bytes').
')';