19 declare(strict_types=1);
48 self::$use_relative_dates = $a_status;
53 return self::$use_relative_dates;
65 $lng = $DIC->language();
77 $lng = $DIC->language();
78 self::setLanguage(
$lng);
79 self::setUseRelativeDates(
true);
84 bool $a_skip_day =
false,
85 bool $a_include_wd =
false,
86 bool $include_seconds =
false,
97 $lng->loadLanguageModule(
'dateplaner');
100 return $lng->txt(
'no_date');
103 $has_time = !$date instanceof
ilDate;
116 if (self::isToday($date) && self::useRelativeDates()) {
117 $date_str =
$lng->txt(
'today');
118 } elseif (self::isTomorrow($date) && self::useRelativeDates()) {
119 $date_str =
$lng->txt(
'tomorrow');
120 } elseif (self::isYesterday($date) && self::useRelativeDates()) {
121 $date_str =
$lng->txt(
'yesterday');
125 $date_str =
$lng->txt(self::$weekdays[$date_info[
'wday']]) .
', ';
127 $date_str .= $date_info[
'mday'] .
'. ' .
143 $sec = ($include_seconds)
147 switch ($user->getTimeFormat()) {
149 return $date_str . $sep .
156 return $date_str . $sep .
177 bool $a_skip_starting_day =
false,
182 $user = $DIC->user();
184 $has_time = !$start instanceof
ilDate;
189 return self::formatDate(
199 if (!$a_skip_starting_day) {
200 $date_str = self::formatDate(
214 switch ($user->getTimeFormat()) {
216 return $date_str . $sep .
223 return $date_str . $sep .
231 switch ($user->getTimeFormat()) {
233 return $date_str . $sep .
242 return $date_str . $sep .
257 $a_skip_starting_day,
278 $ilUser = $DIC[
'ilUser'];
280 if (!is_object(self::$today)) {
294 $ilUser = $DIC[
'ilUser'];
295 if (!is_object(self::$yesterday)) {
310 $ilUser = $DIC[
'ilUser'];
311 if (!is_object(self::$tomorrow)) {
325 bool $force_with_seconds =
false,
337 $seconds = $seconds ?: 0;
341 $days = floor($seconds / 86400);
342 $rest = $seconds % 86400;
344 $hours = floor($rest / 3600);
347 $minutes = floor($rest / 60);
348 $seconds = $rest % 60;
350 $days = ceil($seconds / 86400);
351 $rest = $seconds % 86400;
353 $hours = ceil($rest / 3600);
356 $minutes = ceil($rest / 60);
357 $seconds = $rest % 60;
361 $message = $days .
' ' . ($days == 1 ?
$lng->txt(
'day') :
$lng->txt(
'days'));
367 $message .= ($hours .
' ' . ($hours == 1 ?
$lng->txt(
'hour') :
$lng->txt(
'hours')));
373 $message .= ($minutes .
' ' . ($minutes == 1 ?
$lng->txt(
'minute') :
$lng->txt(
'minutes')));
375 if ($force_with_seconds && $seconds) {
379 $message .= ($seconds .
' ' . ($seconds == 1 ?
$lng->txt(
'second') :
$lng->txt(
'seconds')));
381 if (!$days && !$hours && !$minutes) {
382 return $seconds .
' ' . ($seconds == 1 ?
$lng->txt(
'second') :
$lng->txt(
'seconds'));
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
static array static setUseRelativeDates(bool $a_status)
set use relative dates
static _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
static resetToDefaults()
reset to defaults
static isToday(ilDateTime $date)
Check if date is "today".
static setLanguage(ilLanguage $a_lng)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static useRelativeDates()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static bool $use_relative_dates
static isYesterday(ilDateTime $date)
Check if date is yesterday.
static isTomorrow(ilDateTime $date)
Check if date is tomorrow.
static ilDateTime $tomorrow
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
isNull()
Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)
static ilDateTime $yesterday
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.