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") | |
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) | |
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) ... |
Definition at line 40 of file class.ilFormat.php.
ilFormat::_secondsToShortString | ( | $ | seconds | ) |
converts seconds to string: Long: 7 days 4 hour(s) ...
string | datetime |
Definition at line 563 of file class.ilFormat.php.
References $lng.
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); }
ilFormat::_secondsToString | ( | $ | seconds | ) |
converts seconds to string: Long: 7 days 4 hour(s) ...
string | datetime |
Definition at line 511 of file class.ilFormat.php.
References $lng.
Referenced by ilLearningProgressBaseGUI::__appendLPDetails(), ilLPListOfProgressGUI::__appendUserInfo(), ilCourseContentGUI::__renderItem(), ilCourseContentGUI::__renderUserItem(), ilLearningProgressBaseGUI::__showObjectDetails(), ilInfoScreenGUI::addMetaDataSections(), ilCourseContentGUI::editTimings(), 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; } }
ilFormat::checkDecimal | ( | $ | var | ) |
Prft Zahlen mit Nachkommastellen und erlaubt ein Komma als Nachstellentrenner.
string |
Definition at line 232 of file class.ilFormat.php.
{ return doubleval(ereg_replace (",",".",$var)); }
ilFormat::compareDates | ( | $ | ADate1, | |
$ | ADate2 | |||
) |
Datum vergleichen Erwartet timestamps Liefert das aktuellere Datum als Timestamp zurck.
string | ||
string |
Definition at line 217 of file class.ilFormat.php.
{ if ($ADate1 > $ADate2) { return $ADate1; } return $ADate2; }
ilFormat::dateDB2timestamp | ( | $ | ADatumSQL | ) |
db-datetime to timestamp
string |
Definition at line 125 of file class.ilFormat.php.
{
$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.
string |
Definition at line 141 of file class.ilFormat.php.
Referenced by ilObjGroup::registrationPossible().
{
$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 457 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
string | datetime |
Definition at line 495 of file class.ilFormat.php.
Referenced by ilObjGroup::getExpirationTimestamp().
{ $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
string |
Definition at line 158 of file class.ilFormat.php.
References $t.
Referenced by ilObjGroup::getExpirationDateTime().
ilFormat::fGeld | ( | ) |
formatiert Geldwerte (Format: 00,00 + Eurosymbol).
Weiteres siehe fProzent
Definition at line 241 of file class.ilFormat.php.
{ $num_args = func_num_args(); $geld = func_get_arg(0); if ($num_args == 1) { $test = intval($geld); if (!$test) return " "; } return number_format($geld,2,",",".")." €"; }
ilFormat::fmtDateTime | ( | $ | a_str, | |
$ | a_dateformat, | |||
$ | a_timeformat, | |||
$ | a_mode = "datetime" | |||
) |
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
string | date date, given in sql-format YYYY-MM-DD HH:MM:SS | |
string | date format (default is Y-m-d) | |
string | time format (default is H:i:s) | |
string | format mode (datetime, time or date) |
Definition at line 304 of file class.ilFormat.php.
References $d.
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"; } //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)); } if ($a_mode == "date") { return date($a_dateformat,mktime($h,$i,$s,$m,$d,$y)); } return date($a_dateformat." ".$a_timeformat,mktime($h,$i,$s,$m,$d,$y)); }
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
float | the float to format | |
integer | count of decimals | |
integer | display thousands separator |
Definition at line 361 of file class.ilFormat.php.
{ //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); }
ilFormat::formatDate | ( | $ | a_date, | |
$ | a_mode = "datetime" , |
|||
$ | a_omit_seconds = false | |||
) |
Definition at line 404 of file class.ilFormat.php.
References $lng, and fmtDateTime().
Referenced by ilFileDataImportMail::__readFiles(), ilFileDataImportGroup::__readFiles(), ilFileDataImportForum::__readFiles(), ilObjSurveyGUI::browseForQuestionsObject(), ilQuestionpoolExport::buildExportFileXLS(), ilPersonalDesktopGUI::displayMails(), ilPersonalDesktopGUI::displaySystemMessages(), ilTestEvaluationGUI::evalUserDetail(), exercise(), ilFileDataForum::getFiles(), ilFileDataExercise::getFiles(), ilFileDataForum::getFilesOfPost(), ilFileDataMail::getUnsentFiles(), ilObjAssessmentFolderGUI::logsObject(), ilObjSurveyGUI::maintenanceObject(), ilObjTestGUI::maintenanceObject(), ilObjExerciseGUI::membersObject(), ilTestOutputGUI::outResultsOverview(), ilObjQuestionPoolGUI::printObject(), ilObjTestGUI::questionBrowser(), ilObjSurveyQuestionPoolGUI::questionsObject(), ilObjQuestionPoolGUI::questionsObject(), ilLPItemListGUI::renderObjectInfoXML(), and ilObjTestGUI::statusObject().
{ 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); }
ilFormat::formatUnixTime | ( | $ | ut, | |
$ | with_time = false | |||
) |
Definition at line 437 of file class.ilFormat.php.
References $lng.
Referenced by ilPDFPresentation::__addMain(), ilPDFPresentation::__createObjectDetails(), ilCourseContentGUI::__getItemHTML(), ilLPListOfProgressGUI::__renderContainerRow(), ilLPListOfObjectsGUI::__renderContainerRow(), ilCourseContentGUI::__renderEvent(), ilCourseContentGUI::__renderItem(), ilCourseContentGUI::__renderUserItem(), ilCourseObjectivePresentationGUI::__showLearningMaterials(), ilCourseContentGUI::__showMaterial(), ilObjCourseGUI::__showSubscribers(), ilObjCourseGUI::__showWaitingList(), ilEventAppointment::_appointmentToString(), ilPaymentStatisticGUI::addCustomer(), ilObjPaymentSettingsGUI::addCustomerObject(), ilCourseContentInterface::cci_view(), ilObjCourseGUI::deleteSubscribers(), ilCourseContentGUI::editTimings(), ilObjCourseGUI::fetchPrintSubscriberData(), ilObjCourseGUI::infoScreen(), ilObjCourseGUI::printMembersObject(), ilEventAdministrationGUI::printViewMembers(), ilObjCourseGUI::removeFromWaitingList(), ilLPItemListGUI::renderObjectDetailsXML(), ilLPItemListGUI::renderObjectInfoXML(), ilCourseRegisterGUI::showRegistrationForm(), and ilCourseArchivesGUI::view().
{ global $lng; $format = $lng->txt('lang_dateformat'); if($with_time) { $format .= (' '.$lng->txt('lang_timeformat_no_sec')); } return date($format,$ut); }
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 263 of file class.ilFormat.php.
{ $num_args = func_num_args(); $prozent = func_get_arg(0); if ($num_args == 1) { $test = intval($prozent); if (!$test) return " "; } return number_format($prozent,2,",",".")."%"; }
ilFormat::ftimestamp2dateDB | ( | $ | t | ) |
formats timestamp to db-date
string |
Definition at line 188 of file class.ilFormat.php.
References $t.
Referenced by ilObjSurveyGUI::browseForQuestionsObject(), ilQuestionpoolExport::buildExportFileXLS(), ilObjSurvey::canStartSurvey(), ilTestEvaluationGUI::evalUserDetail(), exercise(), ilObjSurvey::getSurveyCodesTableData(), ilTestOutputGUI::outResultsOverview(), ilObjQuestionPoolGUI::printObject(), ilObjTestGUI::questionBrowser(), ilObjSurveyQuestionPoolGUI::questionsObject(), and ilObjQuestionPoolGUI::questionsObject().
ilFormat::ftimestamp2dateDE | ( | $ | t | ) |
ilFormat::ftimestamp2datetimeDB | ( | $ | aTimestamp | ) |
Timestamp to database datetime.
string | $aTimestamp String in timestamp format |
Definition at line 199 of file class.ilFormat.php.
Referenced by ilTestOutputGUI::endingTimeReached(), ilObjTest::isExecutable(), ilObjAssessmentFolderGUI::logsObject(), ilObjSurveyGUI::maintenanceObject(), and ilObjTestGUI::statusObject().
{ $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; }
ilFormat::ftimestamp2datetimeDE | ( | $ | t | ) |
ilFormat::getDateDE | ( | ) |
Definition at line 48 of file class.ilFormat.php.
Referenced by ilObjGroup::registrationPossible().
{ $date = getdate(); $datum = sprintf("%02d.%02d.%04d", $date["mday"],$date["mon"],$date["year"]); return $datum; }
ilFormat::ilFormat | ( | ) |
Definition at line 42 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).
string |
Definition at line 63 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; } } }
ilFormat::runden | ( | $ | value | ) |
Floats auf 2 Nachkommastellen runden.
float |
Definition at line 284 of file class.ilFormat.php.
{
return round($value * 100) / 100;
}
ilFormat::unixtimestamp2datetime | ( | $ | a_unix_timestamp = "" |
) |
Definition at line 383 of file class.ilFormat.php.
Referenced by ilObjQuestionPool::_clone().
{ 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); } }