ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups 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)
 dateDB2timestamp ($ADatumSQL)
 db-datetime to timestamp
 dateDE2timestamp ($ADatum)
 German datetime to timestamp.
 fdateDB2dateDE ($t)
 formats db-datetime to german date
 ftimestamp2dateDE ($t)
 formats timestamp to german date
 ftimestamp2datetimeDE ($t)
 formats timestamp to german datetime
 ftimestamp2dateDB ($t)
 formats timestamp to db-date
 ftimestamp2datetimeDB ($aTimestamp)
 Timestamp to database datetime.
 compareDates ($ADate1, $ADate2)
 Datum vergleichen Erwartet timestamps Liefert das aktuellere Datum als Timestamp zurck.
 checkDecimal ($var)
 Prft Zahlen mit Nachkommastellen und erlaubt ein Komma als Nachstellentrenner.
 fGeld ()
 formatiert Geldwerte (Format: 00,00 + Eurosymbol).
 fProzent ()
 formatiert Prozentzahlen (Format: 00,00%).
 runden ($value)
 Floats auf 2 Nachkommastellen runden.
 fmtDateTime ($a_str, $a_dateformat, $a_timeformat, $a_mode="datetime", $a_relative=TRUE)
 formatting function for dates
 fmtFloat ($a_float, $a_decimals="", $a_th="")
 format a float
 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
 formatUnixTime ($ut, $with_time=false)
 dateDiff ($a_ts1, $a_ts2)
 datetime2unixTS ($a_datetime)
 converts datetime to a unix timestamp
 _secondsToString ($seconds)
 converts seconds to string: Long: 7 days 4 hour(s) ...
 _secondsToShortString ($seconds)
 converts seconds to string: Long: 7 days 4 hour(s) ...

Detailed Description

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

Member Function Documentation

ilFormat::_secondsToShortString (   $seconds)

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

Parameters
stringdatetime
Returns
integer unix timestamp

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

References $lng, and $rest.

Referenced by ilObjUserFolderGUI\_addLearningProgressWorksheet(), and ilObjUserFolderGUI\learningProgressObject().

{
global $lng;
$seconds = $seconds ? $seconds : 0;
global $lng;
$days = floor($seconds / 86400);
$rest = $seconds % 86400;
$hours = floor($rest / 3600);
$rest = $rest % 3600;
$minutes = floor($rest / 60);
$rest = $rest % 60;
return sprintf("%02d:%02d:%02d:%02d",$days,$hours,$minutes,$rest);
}

+ Here is the caller graph for this function:

ilFormat::_secondsToString (   $seconds)

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

Parameters
stringdatetime
Returns
integer unix timestamp

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

References $lng, and $rest.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), ilLPListOfProgressGUI\__appendUserInfo(), ilCourseContentGUI\__renderItem(), ilCourseContentGUI\__renderUserItem(), ilLearningProgressBaseGUI\__showObjectDetails(), ilInfoScreenGUI\addMetaDataSections(), ilCourseContentGUI\editTimings(), ilCalendarChangedAppointmentsTableGUI\fillRow(), ilCalendarAppointmentsTableGUI\fillRow(), ilObjSCORM2004LearningModule\getTrackingDataAgg(), ilObjUserTrackingGUI\outputTrackingDataObject(), ilLPItemListGUI\renderObjectInfo(), ilLPItemListGUI\renderObjectInfoXML(), and ilInfoScreenGUI\showLearningProgress().

{
global $lng;
$seconds = $seconds ? $seconds : 0;
global $lng;
$days = floor($seconds / 86400);
$rest = $seconds % 86400;
$hours = floor($rest / 3600);
$rest = $rest % 3600;
$minutes = floor($rest / 60);
if($days)
{
$message = $days . ' '. $lng->txt('days');
}
if($hours)
{
if($message)
{
$message .= ' ';
}
$message .= ($hours . ' '. $lng->txt('hours'));
}
if($minutes)
{
if($message)
{
$message .= ' ';
}
$message .= ($minutes . ' '. $lng->txt('minutes'));
}
if(!$days and !$hours and !$minutes)
{
return $seconds .' '. $lng->txt('seconds');
}
else
{
return $message;
}
}

+ Here is the caller graph for this function:

ilFormat::checkDecimal (   $var)

Prft Zahlen mit Nachkommastellen und erlaubt ein Komma als Nachstellentrenner.

Parameters
string

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

Referenced by ilPaymentCouponGUI\saveCouponForm().

{
return doubleval(ereg_replace (",",".",$var));
}

+ Here is the caller graph for this function:

ilFormat::compareDates (   $ADate1,
  $ADate2 
)

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

Parameters
string
string

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

{
if ($ADate1 > $ADate2)
{
return $ADate1;
}
return $ADate2;
}
ilFormat::dateDB2timestamp (   $ADatumSQL)

db-datetime to timestamp

Parameters
string

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

References $timestamp.

{
$timestamp = substr($ADatumSQL, 0, 4).
substr($ADatumSQL, 5, 2).
substr($ADatumSQL, 8, 2).
substr($ADatumSQL, 11, 2).
substr($ADatumSQL, 14, 2).
substr($ADatumSQL, 17, 2);
return $timestamp;
}
ilFormat::dateDE2timestamp (   $ADatum)

German datetime to timestamp.

Parameters
string

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

References $timestamp.

{
$timestamp = substr($ADatum, 6, 4).
substr($ADatum, 3, 2).
substr($ADatum, 0, 2).
substr($ADatum, 11, 2).
substr($ADatum, 14, 2).
substr($ADatum, 17, 2);
return $timestamp;
}
ilFormat::dateDiff (   $a_ts1,
  $a_ts2 
)

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

{
$r = $a_ts2 - $a_ts1;
$dd = floor($r/86400);
if ($dd <= 9)
$dd = "0".$dd;
$r = $r % 86400;
$hh = floor($r/3600);
if ($hh <= 9)
$hh = "0".$hh;
$r = $r % 3600;
$mm = floor($r/60) ;
if ($mm <= 9)
$mm = "0".$mm;
$r = $r % 60;
$ss = $r;
if ($ss <= 9)
$ss = "0".$ss;
return $hh.":".$mm.":".$ss;
}
ilFormat::datetime2unixTS (   $a_datetime)

converts datetime to a unix timestamp

Parameters
stringdatetime
Returns
integer unix timestamp

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

{
$arrDT = explode(" ", $a_datetime);
$arrD = explode("-", $arrDT[0]);
$arrT = explode(":", $arrDT[1]);
return mktime($arrT[0], $arrT[1], $arrT[2], $arrD[1], $arrD[2], $arrD[0]);
}
ilFormat::fdateDB2dateDE (   $t)

formats db-datetime to german date

Parameters
string

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

References $t.

{
return sprintf("%02d.%02d.%04d",substr($t, 8, 2),substr($t, 5, 2),substr($t, 0, 4));
}
ilFormat::fGeld ( )

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

Weiteres siehe fProzent

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

References $test.

{
$num_args = func_num_args();
$geld = func_get_arg(0);
if ($num_args == 1)
{
$test = intval($geld);
if (!$test)
return "&nbsp;";
}
return number_format($geld,2,",",".")." &euro;";
}
ilFormat::fmtDateTime (   $a_str,
  $a_dateformat,
  $a_timeformat,
  $a_mode = "datetime",
  $a_relative = TRUE 
)

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 308 of file class.ilFormat.php.

References $d, $lng, and $timestamp.

Referenced by formatDate().

{
//no format defined. set to default format
if ($a_dateformat == "")
{
$a_dateformat = "Y-m-d";
}
// same for time format
if ($a_timeformat == "")
{
$a_timeformat = "H:i:s";
}
// The sql-date 0000-00-00 00:00:00 means "no-date given"
if ($a_str == '0000-00-00 00:00:00')
{
global $lng;
return $lng->txt('no_date');
}
//
//get values from given sql-date
$d = substr($a_str,8,2);
$m = substr($a_str,5,2);
$y = substr($a_str,0,4);
$h = substr($a_str,11,2);
$i = substr($a_str,14,2);
$s = substr($a_str,17,4);
// Minimum date is 1.1.1970
if(($y < 1970) or
($y == 1970 and ($m < 1 or $d < 1)))
{
$y = 1970;
$m = 1;
$d = 2;
$h = $i = $s = 0;
}
if ($a_mode == "time")
{
return date($a_timeformat,mktime($h,$i,$s,1,1,1999));
}
// BEGIN WebDAV: Display relative date.
$timestamp = mktime($h,$i,$s,$m,$d,$y);
$now = time();
$minuteswest = gettimeofday(false);
$minuteswest = $minuteswest['minuteswest'];
$today = $now - $now % (24 * 60 * 60) + $minuteswest * 60;
$isToday = $today <= $timestamp && $timestamp < $today + 24 * 60 * 60;
$isYesterday = $today - 24 * 60 * 60 <= $timestamp && $timestamp < $today;
$isTomorrow = $today + 24 * 60 * 60 <= $timestamp && $timestamp < $today + 48 * 60 * 60;
global $lng;
if ($a_relative)
{
$date = ($isToday) ? $lng->txt('today') :
(($isYesterday) ? $lng->txt('yesterday') :
(($isTomorrow) ? $lng->txt('tomorrow') :
date($a_dateformat,mktime($h,$i,$s,$m,$d,$y))))
;
}
else
{
$date = date($a_dateformat,mktime($h,$i,$s,$m,$d,$y));
}
return ($a_mode == "date") ? $date : $date.' '.date($a_timeformat,mktime($h,$i,$s,$m,$d,$y));
// END WebDAV: Display relative date.
}

+ Here is the caller graph for this function:

ilFormat::fmtFloat (   $a_float,
  $a_decimals = "",
  $a_th = "" 
)

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
Returns
string formatted number

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

Referenced by ilObjFileAccess\_sizeToString().

{
//thousandskomma?
if (!empty($a_th))
{
if ($a_th == "-lang_sep_thousand-")
{
$a_th = ",";
}
}
//decimalpoint?
$dec = $a_decimals;
if ($dec == "-lang_sep_decimal-")
{
$dec = ".";
}
return number_format($a_float, $a_decimals, $dec, $a_th);
}

+ Here is the caller graph for this function:

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 437 of file class.ilFormat.php.

References $lng, and fmtDateTime().

Referenced by ilObjExercise\__formatBody(), ilFileDataImportForum\__readFiles(), ilFileDataImportMail\__readFiles(), ilFileDataImportGroup\__readFiles(), ilQuestionpoolExport\buildExportFileXLS(), ilTestCertificate\exchangeCertificateVariables(), ilObjCourseGUI\fetchPrintMemberData(), ilShopTopicsTableGUI\fillRow(), ilFileDataExercise\getFiles(), ilFileDataForum\getFiles(), ilFileDataForum\getFilesOfPost(), ilFileDataMail\getUnsentFiles(), ilObjUserGUI\getValues(), ilLMStatisticsGUI\listUsersGroup(), ilLMStatisticsGUI\listUsersRole(), ilTestCertificate\outCertificate(), ilLMStatisticsGUI\search(), ilPaymentCouponGUI\showCoupons(), and ilObjectGUI\viewObject().

{
global $lng;
// return when no datetime is given
if ($a_date == "0000-00-00 00:00:00")
{
return $lng->txt("no_date");
}
$dateformat = $lng->txt("lang_dateformat");
if ($a_omit_seconds && ($lng->txt("lang_timeformat_no_sec") != "-lang_timeformat_no_sec-"))
{
$timeformat = $lng->txt("lang_timeformat_no_sec");
}
else
{
$timeformat = $lng->txt("lang_timeformat");
}
if ($dateformat == "-lang_dateformat-")
{
$dateformat = "";
}
if ($timeformat == "-lang_timeformat-")
{
$timeformat = "";
}
return ilFormat::fmtDateTime($a_date,$dateformat,$timeformat,$a_mode, $a_relative);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $lng.

Referenced by ilPDFPresentation\__addMain(), ilPDFPresentation\__createObjectDetails(), ilMemberExport\createCSV(), ilECSSettingsGUI\exportImported(), ilECSSettingsGUI\exportReleased(), and ilObjCourseGUI\printMembersObject().

{
global $lng;
$format = $lng->txt('lang_dateformat');
if($with_time)
{
$format .= (' '.$lng->txt('lang_timeformat_no_sec'));
}
return date($format,$ut);
}

+ Here is the caller graph for this function:

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 265 of file class.ilFormat.php.

References $test.

{
$num_args = func_num_args();
$prozent = func_get_arg(0);
if ($num_args == 1)
{
$test = intval($prozent);
if (!$test)
return "&nbsp;";
}
return number_format($prozent,2,",",".")."%";
}
ilFormat::ftimestamp2dateDB (   $t)

formats timestamp to db-date

Parameters
string

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

References $t.

Referenced by ilQuestionpoolExport\buildExportFileXLS().

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

+ Here is the caller graph for this function:

ilFormat::ftimestamp2dateDE (   $t)

formats timestamp to german date

Parameters
string

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

References $t.

{
return sprintf("%02d.%02d.%04d",substr($t, 6, 2),substr($t, 4, 2),substr($t, 0, 4));
}
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 201 of file class.ilFormat.php.

Referenced by ilTestOutputGUI\endingTimeReached(), and ilObjTest\isExecutable().

{
$date = "";
if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $aTimestamp, $matches))
{
$date = "$matches[1]-$matches[2]-$matches[3] $matches[4]:$matches[5]:$matches[6]";
}
return $date;
}

+ Here is the caller graph for this function:

ilFormat::ftimestamp2datetimeDE (   $t)

formats timestamp to german datetime

Parameters
string

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

References $t.

{
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));
}
ilFormat::getDateDE ( )

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

{
$date = getdate();
$datum = sprintf("%02d.%02d.%04d", $date["mday"],$date["mon"],$date["year"]);
return $datum;
}
ilFormat::ilFormat ( )

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

{
return;
}
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 65 of file class.ilFormat.php.

References $d.

Referenced by ilObjGroup\setExpirationDateTime().

{
$date=""; $y=""; $m=""; $d="";
// if (ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{2,4})",$idate,$p))
if (ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{2,4})",$AInputDate,$p))
{
$d = $p[1];
$m = $p[2];
$y = $p[3];
if (($d>0 && $d<32) && ($m>0 && $m<13) && (strlen($y)!=3))
{
if (strlen($d) == 1) $d = "0".$d;
if (strlen($m) == 1) $m = "0".$m;
if (strlen($y) == 2)
{
if ($y>=70) $y = $y + 1900;
if ($y<70) $y = $y + 2000;
}
// is valid?
checkdate($m, $d, $y);
// Ausgabe mit Uhrzeit
// Uhrzeit holen
$uhrzeit = substr($AInputDate, -8);
// Uhrzeit auf Gltigkeit prfen
if (ereg("([0-9]{2}):([0-9]{2}):([0-9]{2})",$AInputDate,$p))
{
$h = $p[1];
$min = $p[2];
$s = $p[3];
if (($h>-1 && $h<24) && ($min>-1 && $min<60) && ($s>-1 && $s<60))
{
// Uhrzeit stimmt/ist vorhanden
$date = sprintf("%04d-%02d-%02d %02d:%02d:%02d",$y,$m,$d,$h,$min,$s);
}
}
else
{
// Uhrzeit ist falsch/fehlt; hnge aktuelle Zeit an
$zeit = getdate();
$date = sprintf("%04d-%02d-%02d %02d:%02d:%02d",$y,$m,$d,$zeit["hours"],$zeit["minutes"],$zeit["seconds"]);
}
// Ausgabe ohne Uhrzeit
//$date = sprintf("%04d-%02d-%02d",$y,$m,$d);
return $date;
}
}
}

+ Here is the caller graph for this function:

ilFormat::runden (   $value)

Floats auf 2 Nachkommastellen runden.

Parameters
float

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

{
return round($value * 100) / 100;
}
ilFormat::unixtimestamp2datetime (   $a_unix_timestamp = "")

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

Referenced by ilTestCertificate\exchangeCertificateVariables(), and ilTestCertificate\outCertificate().

{
if (strlen($a_unix_timestamp) == 0)
{
return strftime("%Y-%m-%d %H:%M:%S");
}
else
{
return strftime("%Y-%m-%d %H:%M:%S", $a_unix_timestamp);
}
}

+ Here is the caller graph for this function:


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