ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFormat Class Reference
+ Collaboration diagram for ilFormat:

Public Member Functions

 ilFormat ()
 
 getDateDE ()
 
 input2date ($AInputDate)
 Prft eingegebes Datum und wandelt es in DB-konformen Syntax um Eingabe: TT.MM.JJJJ oder T.M.JJ oder TT.MM.JJJJ HH:MM:SS oder T.M.JJ HH:MM:SS Bei zweistelliger Jahresangabe wird bei YY > 70 19, bei YY < 70 20 vorgestellt Ausgabe: YYYY-MM-DD oder YYYY-MM-DD HH:MM:SS OPTIONAL wird die aktuelle Systemzeit hinzugefgt (Ausgabe: YYYY-MM-DD hh:mm:ss) More...
 
 dateDB2timestamp ($ADatumSQL)
 db-datetime to timestamp More...
 
 dateDE2timestamp ($ADatum)
 German datetime to timestamp. More...
 
 fdateDB2dateDE ($t)
 formats db-datetime to german date More...
 
 ftimestamp2dateDE ($t)
 formats timestamp to german date More...
 
 ftimestamp2datetimeDE ($t)
 formats timestamp to german datetime More...
 
 ftimestamp2dateDB ($t)
 formats timestamp to db-date More...
 
 ftimestamp2datetimeDB ($aTimestamp)
 Timestamp to database datetime. More...
 
 compareDates ($ADate1, $ADate2)
 Datum vergleichen Erwartet timestamps Liefert das aktuellere Datum als Timestamp zurck. More...
 
 checkDecimal ($var)
 Prft Zahlen mit Nachkommastellen und erlaubt ein Komma als Nachstellentrenner. More...
 
 fGeld ()
 formatiert Geldwerte (Format: 00,00 + Eurosymbol). More...
 
 fProzent ()
 formatiert Prozentzahlen (Format: 00,00%). More...
 
 runden ($value)
 Floats auf 2 Nachkommastellen runden. More...
 
 fmtFloat ($a_float, $a_decimals=0, $a_dec_point=null, $a_thousands_sep=null, $a_suppress_dot_zero=false)
 format a float More...
 
 unixtimestamp2datetime ($a_unix_timestamp="")
 
 formatDate ($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
 format a date according to the user language shortcut for Format::fmtDateTime public More...
 
 formatUnixTime ($ut, $with_time=false)
 
 dateDiff ($a_ts1, $a_ts2)
 
 datetime2unixTS ($a_datetime)
 converts datetime to a unix timestamp More...
 
 _secondsToString ($seconds, $force_with_seconds=false, $a_lng=null)
 converts seconds to string: Long: 7 days 4 hour(s) ... More...
 
 _secondsToShortString ($seconds)
 converts seconds to string: Long: 7 days 4 hour(s) ... More...
 

Static Public Member Functions

static fmtDateTime ($a_str, $a_dateformat, $a_timeformat, $a_mode="datetime", $a_relative=TRUE)
 formatting function for dates More...
 
static _getLocalMoneyFormat ($float_number)
 converts a float number to money format, depending on system language More...
 
static _getSizeMagnitude ()
 Returns the magnitude used for size units. More...
 
static formatFloat ($size, $a_decimals, $a_suppress_dot_zero=false, $a_mode='short', $a_lng=null)
 Returns the specified float in human friendly form. More...
 
static formatSize ($size, $a_mode='short', $a_lng=null)
 Returns the specified file size value in a human friendly form. More...
 

Detailed Description

Definition at line 22 of file class.ilFormat.php.

Member Function Documentation

◆ _getLocalMoneyFormat()

static ilFormat::_getLocalMoneyFormat (   $float_number)
static

converts a float number to money format, depending on system language

Definition at line 654 of file class.ilFormat.php.

Referenced by ilPaymentObjectGUI\editPayMethod(), ilPaymentStatisticGUI\showStatistics(), and ilObjPaymentSettingsGUI\updateDetailsObject().

655  {
656  global $ilias;
657 
658  $language = $ilias->getSetting("language");
659  $money_locale = $language.'_'.strtoupper($language);
660  /* de_DE en_US en_EN fr_FR .UTF-8
661  */ //$money_locale = 'de_DE.UTF-8';
662  //vd($_SERVER['HTTP_ACCEPT_LANGUAGE']);
663 
664  setlocale(LC_MONETARY, $money_locale);
665  return $float_number;
666  //return money_format('%!2n', $float_number);
667  }
+ Here is the caller graph for this function:

◆ _getSizeMagnitude()

static ilFormat::_getSizeMagnitude ( )
static

Returns the magnitude used for size units.

This function always returns the value 1024. Thus the value returned by this function is the same value that Windows and Mac OS X return for a file. The value is a GibiBit, MebiBit, KibiBit or byte unit.

For more information about these units see: http://en.wikipedia.org/wiki/Megabyte

Returns
<type>

Definition at line 681 of file class.ilFormat.php.

Referenced by ilObjUserGUI\getValues(), ilObjRoleGUI\loadRoleProperties(), ilObjRoleGUI\readRoleProperties(), ilObjUserGUI\saveObject(), and ilObjUserGUI\updateObject().

682  {
683  return 1024;
684  }
+ Here is the caller graph for this function:

◆ _secondsToShortString()

ilFormat::_secondsToShortString (   $seconds)

converts seconds to string: Long: 7 days 4 hour(s) ...

Parameters
stringdatetime
Returns
integer unix timestamp

Definition at line 628 of file class.ilFormat.php.

References $lng, and $rest.

Referenced by ilUserLPTableGUI\fillRow(), and ilUserLPTableGUI\fillRowExcel().

629  {
630  global $lng;
631 
632  $seconds = $seconds ? $seconds : 0;
633 
634  global $lng;
635 
636  $days = floor($seconds / 86400);
637  $rest = $seconds % 86400;
638 
639  $hours = floor($rest / 3600);
640  $rest = $rest % 3600;
641 
642  $minutes = floor($rest / 60);
643  $rest = $rest % 60;
644 
645  return sprintf("%02d:%02d:%02d:%02d",$days,$hours,$minutes,$rest);
646 
647  }
$rest
Definition: goto.php:85
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ _secondsToString()

ilFormat::_secondsToString (   $seconds,
  $force_with_seconds = false,
  $a_lng = null 
)

converts seconds to string: Long: 7 days 4 hour(s) ...

Parameters
int$secondsseconds
bool$force_with_seconds
ilLanguage$a_lng
Returns
string

Definition at line 549 of file class.ilFormat.php.

References $lng, and $rest.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), ilLearningProgressBaseGUI\__appendUserInfo(), ilRegistrationMimeMailNotification\__construct(), ilCourseContentGUI\__renderItem(), ilCourseContentGUI\__renderUserItem(), ilLearningProgressBaseGUI\__showObjectDetails(), ilInfoScreenGUI\addMetaDataSections(), ilCourseContentGUI\editTimings(), ilTimingOverviewTableGUI\fillRow(), ilCalendarAppointmentsTableGUI\fillRow(), ilTrUserObjectsPropsTableGUI\fillRow(), ilObjSCORM2004LearningModule\getTrackingDataAgg(), ilObjUserFolderGUI\initFormGeneralSettings(), ilPersonalSettingsGUI\initGeneralSettingsForm(), ilLPTableBaseGUI\parseValue(), ilTrSummaryTableGUI\parseValue(), ilInfoScreenGUI\showLearningProgress(), and ilLearningProgressGUI\showtlt().

550  {
551  global $lng;
552 
553  if($a_lng)
554  {
555  $lng = $a_lng;
556  }
557 
558  $seconds = $seconds ? $seconds : 0;
559 
560  // #13625
561  if($seconds > 0)
562  {
563  $days = floor($seconds / 86400);
564  $rest = $seconds % 86400;
565 
566  $hours = floor($rest / 3600);
567  $rest = $rest % 3600;
568 
569  $minutes = floor($rest / 60);
570  $seconds = $rest % 60;
571  }
572  else
573  {
574  $days = ceil($seconds / 86400);
575  $rest = $seconds % 86400;
576 
577  $hours = ceil($rest / 3600);
578  $rest = $rest % 3600;
579 
580  $minutes = ceil($rest / 60);
581  $seconds = $rest % 60;
582  }
583 
584  if($days)
585  {
586  $message = $days . ' '. ($days == 1 ? $lng->txt('day') : $lng->txt('days'));
587  }
588  if($hours)
589  {
590  if($message)
591  {
592  $message .= ' ';
593  }
594  $message .= ($hours . ' '. ($hours == 1 ? $lng->txt('hour') : $lng->txt('hours')));
595  }
596  if($minutes)
597  {
598  if($message)
599  {
600  $message .= ' ';
601  }
602  $message .= ($minutes . ' '. ($minutes == 1 ? $lng->txt('minute') : $lng->txt('minutes')));
603  }
604  if($force_with_seconds && $seconds)
605  {
606  if($message)
607  {
608  $message .= ' ';
609  }
610  $message .= ($seconds . ' '. ($seconds == 1 ? $lng->txt('second') : $lng->txt('seconds')));
611  }
612  if(!$days and !$hours and !$minutes)
613  {
614  return $seconds .' '. ($seconds == 1 ? $lng->txt('second') : $lng->txt('seconds'));
615  }
616  else
617  {
618  return $message;
619  }
620  }
$rest
Definition: goto.php:85
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ checkDecimal()

ilFormat::checkDecimal (   $var)

Prft Zahlen mit Nachkommastellen und erlaubt ein Komma als Nachstellentrenner.

Parameters
string

Definition at line 214 of file class.ilFormat.php.

Referenced by ilPaymentCouponGUI\saveCouponForm().

215  {
216  return doubleval(ereg_replace (",",".",$var));
217  }
+ Here is the caller graph for this function:

◆ compareDates()

ilFormat::compareDates (   $ADate1,
  $ADate2 
)

Datum vergleichen Erwartet timestamps Liefert das aktuellere Datum als Timestamp zurck.

Parameters
string
string

Definition at line 199 of file class.ilFormat.php.

200  {
201  if ($ADate1 > $ADate2)
202  {
203  return $ADate1;
204  }
205 
206  return $ADate2;
207  }

◆ dateDB2timestamp()

ilFormat::dateDB2timestamp (   $ADatumSQL)

db-datetime to timestamp

Parameters
string

Definition at line 107 of file class.ilFormat.php.

References $timestamp.

Referenced by ilObjTestSettingsGeneralGUI\saveTestAccessProperties().

108  {
109  $timestamp = substr($ADatumSQL, 0, 4).
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);
115 
116  return $timestamp;
117  }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
+ Here is the caller graph for this function:

◆ dateDE2timestamp()

ilFormat::dateDE2timestamp (   $ADatum)

German datetime to timestamp.

Parameters
string

Definition at line 123 of file class.ilFormat.php.

References $timestamp.

124  {
125  $timestamp = substr($ADatum, 6, 4).
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);
131 
132  return $timestamp;
133  }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81

◆ dateDiff()

ilFormat::dateDiff (   $a_ts1,
  $a_ts2 
)

Definition at line 493 of file class.ilFormat.php.

References $r.

494  {
495  $r = $a_ts2 - $a_ts1;
496 
497  $dd = floor($r/86400);
498 
499  if ($dd <= 9)
500  $dd = "0".$dd;
501 
502  $r = $r % 86400;
503 
504  $hh = floor($r/3600);
505 
506  if ($hh <= 9)
507  $hh = "0".$hh;
508 
509  $r = $r % 3600;
510 
511  $mm = floor($r/60) ;
512 
513  if ($mm <= 9)
514  $mm = "0".$mm;
515 
516  $r = $r % 60;
517  $ss = $r;
518 
519  if ($ss <= 9)
520  $ss = "0".$ss;
521 
522  return $hh.":".$mm.":".$ss;
523  }
$r

◆ datetime2unixTS()

ilFormat::datetime2unixTS (   $a_datetime)

converts datetime to a unix timestamp

Parameters
stringdatetime
Returns
integer unix timestamp

Definition at line 531 of file class.ilFormat.php.

532  {
533  $arrDT = explode(" ", $a_datetime);
534  $arrD = explode("-", $arrDT[0]);
535  $arrT = explode(":", $arrDT[1]);
536 
537  return mktime($arrT[0], $arrT[1], $arrT[2], $arrD[1], $arrD[2], $arrD[0]);
538  }

◆ fdateDB2dateDE()

ilFormat::fdateDB2dateDE (   $t)

formats db-datetime to german date

Parameters
string

Definition at line 140 of file class.ilFormat.php.

References $t.

141  {
142  return sprintf("%02d.%02d.%04d",substr($t, 8, 2),substr($t, 5, 2),substr($t, 0, 4));
143  }

◆ fGeld()

ilFormat::fGeld ( )

formatiert Geldwerte (Format: 00,00 + Eurosymbol).

Weiteres siehe fProzent

Definition at line 223 of file class.ilFormat.php.

References $test.

224  {
225  $num_args = func_num_args();
226 
227  $geld = func_get_arg(0);
228 
229  if ($num_args == 1)
230  {
231  $test = intval($geld);
232 
233  if (!$test)
234  return "&nbsp;";
235  }
236 
237  return number_format($geld,2,",",".")." &euro;";
238  }
$test
Definition: Utf8Test.php:85

◆ fmtDateTime()

static ilFormat::fmtDateTime (   $a_str,
  $a_dateformat,
  $a_timeformat,
  $a_mode = "datetime",
  $a_relative = TRUE 
)
static

formatting function for dates

In different languages, dates are formatted different. fmtDate expects a sql timestamp and a date format. Optional you may specify a time format. If you skip this parameter no time is displayed The format options follows the rules of the PHP date-function. See in the PHP manual for a list of possible formatting options public

Parameters
stringdate date, given in sql-format YYYY-MM-DD HH:MM:SS
stringdate format (default is Y-m-d)
stringtime format (default is H:i:s)
stringformat mode (datetime, time or date)
booleanrelative date output
Returns
string formatted date
Deprecated:
since 3.10 - 05.03.2009

Definition at line 288 of file class.ilFormat.php.

References $d, $lng, and $timestamp.

Referenced by formatDate(), and assFileUpload\hasFileUploads().

289  {
290  //no format defined. set to default format
291  if ($a_dateformat == "")
292  {
293  $a_dateformat = "Y-m-d";
294  }
295 
296  // same for time format
297  if ($a_timeformat == "")
298  {
299  $a_timeformat = "H:i:s";
300  }
301 
302  // The sql-date 0000-00-00 00:00:00 means "no-date given"
303  if ($a_str == '0000-00-00 00:00:00')
304  {
305  global $lng;
306  return $lng->txt('no_date');
307  }
308  //
309  //get values from given sql-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);
316 
317  // Minimum date is 1.1.1970
318  if(($y < 1970) or
319  ($y == 1970 and ($m < 1 or $d < 1)))
320  {
321  $y = 1970;
322  $m = 1;
323  $d = 2;
324  $h = $i = $s = 0;
325  }
326 
327  if ($a_mode == "time")
328  {
329  return date($a_timeformat,mktime($h,$i,$s,1,1,1999));
330  }
331 
332  // BEGIN WebDAV: Display relative date.
333  $timestamp = mktime($h,$i,$s,$m,$d,$y);
334  $now = time();
335  $minuteswest = gettimeofday(false);
336  $minuteswest = $minuteswest['minuteswest'];
337  $today = $now - $now % (24 * 60 * 60) + $minuteswest * 60;
338  $isToday = $today <= $timestamp && $timestamp < $today + 24 * 60 * 60;
339  $isYesterday = $today - 24 * 60 * 60 <= $timestamp && $timestamp < $today;
340  $isTomorrow = $today + 24 * 60 * 60 <= $timestamp && $timestamp < $today + 48 * 60 * 60;
341 
342  global $lng;
343  if ($a_relative)
344  {
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))))
349  ;
350  }
351  else
352  {
353  $date = date($a_dateformat,mktime($h,$i,$s,$m,$d,$y));
354  }
355 
356  return ($a_mode == "date") ? $date : $date.' '.date($a_timeformat,mktime($h,$i,$s,$m,$d,$y));
357  // END WebDAV: Display relative date.
358  }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ fmtFloat()

ilFormat::fmtFloat (   $a_float,
  $a_decimals = 0,
  $a_dec_point = null,
  $a_thousands_sep = null,
  $a_suppress_dot_zero = false 
)

format a float

this functions takes php's number_format function and formats the given value with appropriate thousand and decimal separator. public

Parameters
floatthe float to format
integercount of decimals
integerdisplay thousands separator
booleanwhether .0 should be suppressed
Returns
string formatted number

Definition at line 373 of file class.ilFormat.php.

References $lng, and $txt.

374  {
375  global $lng;
376 
377 
378  if ($a_dec_point == null)
379  {
380  $a_dec_point = $lng->txt('lang_sep_decimal');
381  {
382  $a_dec_point = ".";
383  }
384  }
385  if ($a_dec_point == '-lang_sep_decimal-')
386  {
387  $a_dec_point = ".";
388  }
389 
390  if ($a_thousands_sep == null)
391  {
392  $a_thousands_sep = $lng->txt('lang_sep_thousand');
393  {
394  $a_th = ",";
395  }
396  }
397  if ($a_thousands_sep == '-lang_sep_thousand-')
398  {
399  $a_thousands_sep = ",";
400  }
401 
402  $txt = number_format($a_float, $a_decimals, $a_dec_point, $a_thousands_sep);
403 
404  // remove trailing ".0"
405  if (($a_suppress_dot_zero == 0 || $a_decimal == 0) &&
406  substr($txt,-2) == $a_dec_point.'0')
407  {
408  $txt = substr($txt, 0, strlen($txt) - 2);
409  }
410  if ($a_float == 0 and $txt == "")
411  {
412  $txt = "0";
413  }
414  return $txt;
415  }
$txt
Definition: error.php:10
global $lng
Definition: privfeed.php:40

◆ formatDate()

ilFormat::formatDate (   $a_date,
  $a_mode = "datetime",
  $a_omit_seconds = false,
  $a_relative = TRUE 
)

format a date according to the user language shortcut for Format::fmtDateTime public

Parameters
stringsql date
stringformat mode
booleanRelative date output
Returns
string formatted date
See also
Format::fmtDateTime
Deprecated:
since 3.10 - 05.03.2009

Definition at line 440 of file class.ilFormat.php.

References $lng, and fmtDateTime().

Referenced by ilObjExercise\__formatBody(), ilFileDataImportMail\__readFiles(), ilFileDataImportGroup\__readFiles(), ilQuestionpoolExport\buildExportFileXLS(), ilTestExport\exportToCSV(), ilShopTopicsTableGUI\fillRow(), ilFSStorageExercise\getFiles(), ilFileDataForum\getForumPath(), ilObjUserGUI\getValues(), and ilObjFileAccessSettingsGUI\viewDiskQuotaReport().

441  {
442  global $lng;
443 
444  // return when no datetime is given
445  if ($a_date == "0000-00-00 00:00:00")
446  {
447  return $lng->txt("no_date");
448  }
449 
450  $dateformat = $lng->txt("lang_dateformat");
451  if ($a_omit_seconds && ($lng->txt("lang_timeformat_no_sec") != "-lang_timeformat_no_sec-"))
452  {
453  $timeformat = $lng->txt("lang_timeformat_no_sec");
454  }
455  else
456  {
457  $timeformat = $lng->txt("lang_timeformat");
458  }
459 
460  if ($dateformat == "-lang_dateformat-")
461  {
462  $dateformat = "";
463  }
464 
465  if ($timeformat == "-lang_timeformat-")
466  {
467  $timeformat = "";
468  }
469 
470  return ilFormat::fmtDateTime($a_date,$dateformat,$timeformat,$a_mode, $a_relative);
471  }
static fmtDateTime($a_str, $a_dateformat, $a_timeformat, $a_mode="datetime", $a_relative=TRUE)
formatting function for dates
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatFloat()

static ilFormat::formatFloat (   $size,
  $a_decimals,
  $a_suppress_dot_zero = false,
  $a_mode = 'short',
  $a_lng = null 
)
static

Returns the specified float in human friendly form.

Parameters
floata float
ilLanguageThe language object, or null if you want to use the system language.

Definition at line 692 of file class.ilFormat.php.

References $lng, and $size.

Referenced by ilDiskQuotaReminderMail\replacePlaceholders().

693  {
694  global $lng;
695  if ($a_lng == null) {
696  $a_lng = $lng;
697  }
698  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);
699  }
$size
Definition: RandomTest.php:79
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ formatSize()

static ilFormat::formatSize (   $size,
  $a_mode = 'short',
  $a_lng = null 
)
static

Returns the specified file size value in a human friendly form.

By default, the oder of magnitude 1024 is used. Thus the value returned by this function is the same value that Windows and Mac OS X return for a file. The value is a GibiBig, MebiBit, KibiBit or byte unit.

For more information about these units see: http://en.wikipedia.org/wiki/Megabyte

Parameters
integersize in bytes
stringmode: "short" is useful for display in the repository "long" is useful for display on the info page of an object
ilLanguageThe language object, or null if you want to use the system language.

Definition at line 716 of file class.ilFormat.php.

References $lng, $result, and $size.

Referenced by ilInfoScreenGUI\addObjectSections(), ilMailAttachmentGUI\executeCommand(), ilFileVersionTableGUI\fillRow(), ilExportTableGUI\fillRow(), ilMailAttachmentTableGUI\formatValue(), ilObjFileListGUI\getProperties(), ilDiskQuotaHandler\getStatusLegend(), ilMailAttachmentGUI\getToolbarForm(), ilObjFileGUI\infoScreenForward(), ilObjUserGUI\initForm(), outMobImageParams(), ilDiskQuotaReminderMail\replacePlaceholders(), ilDiskQuotaSummaryNotification\send(), ilLMPresentationGUI\showDownloadList(), ilMailFormGUI\showForm(), and ilObjFileAccessSettingsGUI\viewDiskQuotaReport().

717  {
718  global $lng;
719  if ($a_lng == null) {
720  $a_lng = $lng;
721  }
722 
723  $result;
724  $mag = self::_getSizeMagnitude();
725 
726  $scaled_size;
727  $scaled_unit;
728 
729  if ($size >= $mag * $mag * $mag)
730  {
731  $scaled_size = $size/$mag/$mag/$mag;
732  $scaled_unit = 'lang_size_gb';
733  }
734  else if ($size >= $mag * $mag)
735  {
736  $scaled_size = $size/$mag/$mag;
737  $scaled_unit = 'lang_size_mb';
738  }
739  else if ($size >= $mag)
740  {
741  $scaled_size = $size/$mag;
742  $scaled_unit = 'lang_size_kb';
743  }
744  else
745  {
746  $scaled_size = $size;
747  $scaled_unit = 'lang_size_bytes';
748  }
749 
750  $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);
751  if ($a_mode == 'long' && $size > $mag)
752  {
753  $result .= ' ('.
754  self::fmtFloat($size,0,$a_lng->txt('lang_sep_decimal'),$a_lng->txt('lang_sep_thousand')).
755  ' '.$a_lng->txt('lang_size_bytes').')';
756  }
757  return $result;
758  }
$size
Definition: RandomTest.php:79
$result
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ formatUnixTime()

ilFormat::formatUnixTime (   $ut,
  $with_time = false 
)

Definition at line 473 of file class.ilFormat.php.

References $lng.

Referenced by ilECSSettingsGUI\exportImported(), ilECSSettingsGUI\exportReleased(), ilAttendanceList\getHTML(), and ilMemberExport\write().

474  {
475  global $lng;
476 
477  $format = $lng->txt('lang_dateformat');
478 
479  if($with_time)
480  {
481  $format .= (' '.$lng->txt('lang_timeformat_no_sec'));
482  }
483  return date($format,$ut);
484  }
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ fProzent()

ilFormat::fProzent ( )

formatiert Prozentzahlen (Format: 00,00%).

Wenn nix oder eine Null bergeben wird, wird ein Leerzeichen zurckgegeben Wenn mehr als ein Parameter bergeben wird, wird die Ausgabe auch bei Wert Null erzwungen

Definition at line 245 of file class.ilFormat.php.

References $test.

246  {
247  $num_args = func_num_args();
248 
249  $prozent = func_get_arg(0);
250 
251  if ($num_args == 1)
252  {
253  $test = intval($prozent);
254 
255  if (!$test)
256  return "&nbsp;";
257  }
258 
259  return number_format($prozent,2,",",".")."%";
260  }
$test
Definition: Utf8Test.php:85

◆ ftimestamp2dateDB()

ilFormat::ftimestamp2dateDB (   $t)

formats timestamp to db-date

Parameters
string

Definition at line 170 of file class.ilFormat.php.

References $t.

171  {
172  return sprintf("%04d-%02d-%02d",substr($t, 0, 4),substr($t, 4, 2),substr($t, 6, 2));
173  }

◆ ftimestamp2dateDE()

ilFormat::ftimestamp2dateDE (   $t)

formats timestamp to german date

Parameters
string

Definition at line 150 of file class.ilFormat.php.

References $t.

151  {
152  return sprintf("%02d.%02d.%04d",substr($t, 6, 2),substr($t, 4, 2),substr($t, 0, 4));
153  }

◆ ftimestamp2datetimeDB()

ilFormat::ftimestamp2datetimeDB (   $aTimestamp)

Timestamp to database datetime.

Parameters
string$aTimestampString in timestamp format
Returns
string Database datetime in format yyyy-mm-dd hh:mm:ss

Definition at line 181 of file class.ilFormat.php.

Referenced by ilTestPlayerAbstractGUI\endingTimeReached().

182  {
183  $date = "";
184  if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $aTimestamp, $matches))
185  {
186  $date = "$matches[1]-$matches[2]-$matches[3] $matches[4]:$matches[5]:$matches[6]";
187  }
188  return $date;
189  }
+ Here is the caller graph for this function:

◆ ftimestamp2datetimeDE()

ilFormat::ftimestamp2datetimeDE (   $t)

formats timestamp to german datetime

Parameters
string

Definition at line 160 of file class.ilFormat.php.

References $t.

161  {
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));
163  }

◆ getDateDE()

ilFormat::getDateDE ( )

Definition at line 30 of file class.ilFormat.php.

31  {
32  $date = getdate();
33  $datum = sprintf("%02d.%02d.%04d", $date["mday"],$date["mon"],$date["year"]);
34  return $datum;
35  }

◆ ilFormat()

ilFormat::ilFormat ( )

Definition at line 24 of file class.ilFormat.php.

25  {
26  return;
27  }

◆ input2date()

ilFormat::input2date (   $AInputDate)

Prft eingegebes Datum und wandelt es in DB-konformen Syntax um Eingabe: TT.MM.JJJJ oder T.M.JJ oder TT.MM.JJJJ HH:MM:SS oder T.M.JJ HH:MM:SS Bei zweistelliger Jahresangabe wird bei YY > 70 19, bei YY < 70 20 vorgestellt Ausgabe: YYYY-MM-DD oder YYYY-MM-DD HH:MM:SS OPTIONAL wird die aktuelle Systemzeit hinzugefgt (Ausgabe: YYYY-MM-DD hh:mm:ss)

Parameters
string

Definition at line 45 of file class.ilFormat.php.

References $d.

46  {
47 
48  $date=""; $y=""; $m=""; $d="";
49 // if (ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{2,4})",$idate,$p))
50  if (ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{2,4})",$AInputDate,$p))
51  {
52 
53  $d = $p[1];
54  $m = $p[2];
55  $y = $p[3];
56 
57  if (($d>0 && $d<32) && ($m>0 && $m<13) && (strlen($y)!=3))
58  {
59  if (strlen($d) == 1) $d = "0".$d;
60  if (strlen($m) == 1) $m = "0".$m;
61 
62  if (strlen($y) == 2)
63  {
64  if ($y>=70) $y = $y + 1900;
65  if ($y<70) $y = $y + 2000;
66  }
67 
68  // is valid?
69  checkdate($m, $d, $y);
70 
71  // Ausgabe mit Uhrzeit
72 
73  // Uhrzeit holen
74  $uhrzeit = substr($AInputDate, -8);
75 
76  // Uhrzeit auf Gltigkeit prfen
77  if (ereg("([0-9]{2}):([0-9]{2}):([0-9]{2})",$AInputDate,$p))
78  {
79  $h = $p[1];
80  $min = $p[2];
81  $s = $p[3];
82 
83  if (($h>-1 && $h<24) && ($min>-1 && $min<60) && ($s>-1 && $s<60))
84  {
85  // Uhrzeit stimmt/ist vorhanden
86  $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d",$y,$m,$d,$h,$min,$s);
87  }
88  }
89  else
90  {
91  // Uhrzeit ist falsch/fehlt; hnge aktuelle Zeit an
92  $zeit = getdate();
93  $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d",$y,$m,$d,$zeit["hours"],$zeit["minutes"],$zeit["seconds"]);
94  }
95  // Ausgabe ohne Uhrzeit
96  //$date = sprintf("%04d-%02d-%02d",$y,$m,$d);
97  return $date;
98  }
99  }
100  }

◆ runden()

ilFormat::runden (   $value)

Floats auf 2 Nachkommastellen runden.

Parameters
float

Definition at line 266 of file class.ilFormat.php.

267  {
268  return round($value * 100) / 100;
269  }

◆ unixtimestamp2datetime()

ilFormat::unixtimestamp2datetime (   $a_unix_timestamp = "")

Definition at line 417 of file class.ilFormat.php.

Referenced by assFileUpload\hasFileUploads().

418  {
419  if (strlen($a_unix_timestamp) == 0)
420  {
421  return strftime("%Y-%m-%d %H:%M:%S");
422  }
423  else
424  {
425  return strftime("%Y-%m-%d %H:%M:%S", $a_unix_timestamp);
426  }
427  }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: