24 include_once(
'./Services/Calendar/classes/class.ilDate.php');
25 include_once(
'./Services/Calendar/classes/class.ilCalendarSettings.php');
62 self::$use_relative_dates = $a_status;
73 return self::$use_relative_dates;
114 self::setLanguage(
$lng);
115 self::setUseRelativeDates(
true);
128 $include_seconds =
false)
136 return self::getLanguage()->txt(
'no_date');
139 $has_time = !is_a($date,
'ilDate');
150 if (self::isToday($date)
and self::useRelativeDates()) {
151 $date_str = self::getLanguage()->txt(
'today');
152 } elseif (self::isTomorrow($date)
and self::useRelativeDates()) {
153 $date_str = self::getLanguage()->txt(
'tomorrow');
154 } elseif (self::isYesterday($date)
and self::useRelativeDates()) {
155 $date_str = self::getLanguage()->txt(
'yesterday');
157 include_once(
'./Services/Calendar/classes/class.ilCalendarUtil.php');
174 $sec = ($include_seconds)
178 switch (
$ilUser->getTimeFormat()) {
205 $has_time = !is_a($start,
'ilDate');
210 return self::formatDate($start);
214 if (!$a_skip_starting_day) {
215 $date_str = self::formatDate(
223 switch (
$ilUser->getTimeFormat()) {
231 switch (
$ilUser->getTimeFormat()) {
244 return self::formatDate($start, $a_skip_starting_day) .
' - ' . self::formatDate($end);
263 if (!is_object(self::$today)) {
283 if (!is_object(self::$yesterday)) {
305 if (!is_object(self::$tomorrow)) {
322 public static function secondsToString($seconds, $force_with_seconds =
false, $a_lng = null)
332 $seconds = $seconds ? $seconds : 0;
336 $days = floor($seconds / 86400);
337 $rest = $seconds % 86400;
339 $hours = floor(
$rest / 3600);
342 $minutes = floor(
$rest / 60);
343 $seconds =
$rest % 60;
345 $days = ceil($seconds / 86400);
346 $rest = $seconds % 86400;
348 $hours = ceil(
$rest / 3600);
351 $minutes = ceil(
$rest / 60);
352 $seconds =
$rest % 60;
356 $message = $days .
' ' . ($days == 1 ?
$lng->txt(
'day') :
$lng->txt(
'days'));
362 $message .= ($hours .
' ' . ($hours == 1 ?
$lng->txt(
'hour') :
$lng->txt(
'hours')));
368 $message .= ($minutes .
' ' . ($minutes == 1 ?
$lng->txt(
'minute') :
$lng->txt(
'minutes')));
370 if ($force_with_seconds && $seconds) {
374 $message .= ($seconds .
' ' . ($seconds == 1 ?
$lng->txt(
'second') :
$lng->txt(
'seconds')));
376 if (!$days
and !$hours
and !$minutes) {
377 return $seconds .
' ' . ($seconds == 1 ?
$lng->txt(
'second') :
$lng->txt(
'seconds'));
static resetToDefaults()
reset to defaults
static setUseRelativeDates($a_status)
set use relative dates
static isToday(ilDateTime $date)
Check if date is "today".
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
static useRelativeDates()
check if relative dates are used
static setLanguage($a_lng)
set language
Class for date presentation.
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
catch(Exception $e) $message
static $use_relative_dates
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static isYesterday(ilDateTime $date)
Check if date is yesterday.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
increment($a_type, $a_count=1)
increment
static isTomorrow(ilDateTime $date)
Check if date is tomorrow.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
static getLanguage()
set language
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
isNull()
Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)