24include_once(
'./Services/Calendar/classes/class.ilDate.php');
25include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
62 self::$use_relative_dates = $a_status;
131 $has_time = !is_a($date,
'ilDate');
142 if (self::isToday($date) and self::useRelativeDates()) {
144 } elseif (self::isTomorrow($date) and self::useRelativeDates()) {
146 } elseif (self::isYesterday($date) and self::useRelativeDates()) {
149 include_once(
'./Services/Calendar/classes/class.ilCalendarUtil.php');
166 switch (
$ilUser->getTimeFormat()) {
191 $has_time = !is_a($start,
'ilDate');
200 if (!$a_skip_starting_day) {
209 switch (
$ilUser->getTimeFormat()) {
217 switch (
$ilUser->getTimeFormat()) {
247 if (!is_object(self::$today)) {
265 if (!is_object(self::$yesterday)) {
285 if (!is_object(self::$tomorrow)) {
302 public static function secondsToString($seconds, $force_with_seconds =
false, $a_lng =
null)
310 $seconds = $seconds ? $seconds : 0;
314 $days = floor($seconds / 86400);
315 $rest = $seconds % 86400;
317 $hours = floor(
$rest / 3600);
320 $minutes = floor(
$rest / 60);
321 $seconds =
$rest % 60;
323 $days = ceil($seconds / 86400);
324 $rest = $seconds % 86400;
326 $hours = ceil(
$rest / 3600);
329 $minutes = ceil(
$rest / 60);
330 $seconds =
$rest % 60;
334 $message = $days .
' ' . ($days == 1 ?
$lng->txt(
'day') :
$lng->txt(
'days'));
340 $message .= ($hours .
' ' . ($hours == 1 ?
$lng->txt(
'hour') :
$lng->txt(
'hours')));
346 $message .= ($minutes .
' ' . ($minutes == 1 ?
$lng->txt(
'minute') :
$lng->txt(
'minutes')));
348 if ($force_with_seconds && $seconds) {
352 $message .= ($seconds .
' ' . ($seconds == 1 ?
$lng->txt(
'second') :
$lng->txt(
'seconds')));
354 if (!$days and !$hours and !$minutes) {
355 return $seconds .
' ' . ($seconds == 1 ?
$lng->txt(
'second') :
$lng->txt(
'seconds'));
An exception for terminatinating execution or to throw for unit testing.
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
Class for date presentation.
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static isTomorrow(ilDateTime $date)
Check if date is tomorrow.
static isYesterday(ilDateTime $date)
Check if date is yesterday.
static getLanguage()
set language
static resetToDefaults()
reset to defaults
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
static $use_relative_dates
static setLanguage($a_lng)
set language
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
static isToday(ilDateTime $date)
Check if date is "today".
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
isNull()
Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)
catch(Exception $e) $message