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;
110 self::setLanguage($lng);
111 self::setUseRelativeDates(
true);
128 return self::getLanguage()->txt(
'no_date');
131 $has_time = !is_a($date,
'ilDate');
142 if (self::isToday($date) and self::useRelativeDates()) {
143 $date_str = self::getLanguage()->txt(
'today');
144 } elseif (self::isTomorrow($date) and self::useRelativeDates()) {
145 $date_str = self::getLanguage()->txt(
'tomorrow');
146 } elseif (self::isYesterday($date) and self::useRelativeDates()) {
147 $date_str = self::getLanguage()->txt(
'yesterday');
149 include_once(
'./Services/Calendar/classes/class.ilCalendarUtil.php');
166 switch ($ilUser->getTimeFormat()) {
171 return $date_str . $sep . $date->
get(
IL_CAL_FKT_DATE,
'g:ia', $ilUser->getTimeZone());
191 $has_time = !is_a($start,
'ilDate');
196 return self::formatDate($start);
200 if (!$a_skip_starting_day) {
201 $date_str = self::formatDate(
209 switch ($ilUser->getTimeFormat()) {
211 return $date_str . $sep . $start->
get(
IL_CAL_FKT_DATE,
'H:i', $ilUser->getTimeZone());
214 return $date_str . $sep . $start->
get(
IL_CAL_FKT_DATE,
'h:i a', $ilUser->getTimeZone());
217 switch ($ilUser->getTimeFormat()) {
219 return $date_str . $sep . $start->
get(
IL_CAL_FKT_DATE,
'H:i', $ilUser->getTimeZone()) .
' - ' .
223 return $date_str . $sep . $start->
get(
IL_CAL_FKT_DATE,
'g:ia', $ilUser->getTimeZone()) .
' - ' .
230 return self::formatDate($start, $a_skip_starting_day) .
' - ' . self::formatDate($end);
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'));
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
static resetToDefaults()
reset to defaults
static setUseRelativeDates($a_status)
set use relative dates
static isToday(ilDateTime $date)
Check if date is "today".
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
Create styles array
The data for the language used.
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
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
isNull()
Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)