ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDatePresentation Class Reference

Class for date presentation. More...

+ Collaboration diagram for ilDatePresentation:

Static Public Member Functions

static setUseRelativeDates ($a_status)
 set use relative dates More...
 
static useRelativeDates ()
 check if relative dates are used More...
 
static setLanguage ($a_lng)
 set language More...
 
static getLanguage ()
 set language More...
 
static resetToDefaults ()
 reset to defaults More...
 
static formatDate (ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
 Format a date public. More...
 
static formatPeriod (ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
 Format a period of two date Shows: 14. More...
 
static isToday (ilDateTime $date)
 Check if date is "today". More...
 
static isYesterday (ilDateTime $date)
 Check if date is yesterday. More...
 
static isTomorrow (ilDateTime $date)
 Check if date is tomorrow. More...
 
static secondsToString ($seconds, $force_with_seconds=false, $a_lng=null)
 converts seconds to string: Long: 7 days 4 hour(s) ... More...
 

Static Public Attributes

static $use_relative_dates = true
 
static $today = null
 
static $tomorrow = null
 
static $yesterday = null
 

Static Protected Attributes

static $weekdays
 

Static Private Attributes

static $lang = null
 

Detailed Description

Class for date presentation.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 35 of file class.ilDatePresentation.php.

Member Function Documentation

◆ formatDate()

static ilDatePresentation::formatDate ( ilDateTime  $date,
  $a_skip_day = false,
  $a_include_wd = false 
)
static

Format a date public.

Parameters
object$dateilDate or ilDateTime
Returns
string date presentation in user specific timezone and language

Definition at line 123 of file class.ilDatePresentation.php.

References $ilUser, $lng, ilCalendarUtil\_numericMonthToString(), ilDateTime\get(), IL_CAL_FKT_DATE, IL_CAL_FKT_GETDATE, ilDateTime\isNull(), ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), ilLearningProgressBaseGUI\__appendUserInfo(), ilChatroomHistoryGUI\__construct(), ilFileVersionTableGUI\__construct(), ilPDMailGUI\__construct(), ilRegistrationSettingsGUI\__prepareAccessLimitationRoleList(), ilCourseContentGUI\__renderItem(), ilCourseContentGUI\__renderUserItem(), ilObjGroupAccess\_checkAccess(), ilObjCourseAccess\_checkAccess(), ilObject\_lookupLastUpdate(), ilObjRemoteFile\_lookupVersionInfo(), ilObjRemoteFileGUI\addCustomInfoFields(), ilAppointmentPresentationGUI\addLastUpdate(), ilInfoScreenGUI\addObjectSections(), ilExAssignmentGUI\addSchedule(), ilExAssignmentGUI\addSubmission(), ilObjBookingPoolGUI\buildDatesBySchedule(), ilMailFolderGUI\cancelDeleteMails(), ilObjSurvey\canStartSurvey(), ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), ilConsultationHoursGUI\confirmDelete(), ilMemberExportGUI\confirmDeleteExportFile(), ilSCORM2004ScoGUI\confirmDeleteExportFile(), ilObjSCORM2004LearningModuleGUI\confirmDeleteExportFile(), ilObjSurveyQuestionPoolGUI\confirmDeleteExportFileObject(), ilObjLanguageFolderGUI\confirmRefreshSelectedObject(), ilCalendarAppointmentGUI\confirmRegister(), ilConsultationHoursGUI\confirmRejectBooking(), ilCalendarAppointmentGUI\confirmUnregister(), ilForum\convertDate(), ilPersonalSettingsGUI\deleteOwnAccount4(), ilObjUser\deleteUserDefinedFieldEntries(), ilTestEvaluationGUI\detailedEvaluation(), ilObjForumGUI\doHistoryCheck(), ilPageObjectGUI\edit(), ilExSubmissionTextGUI\editAssignmentTextObject(), ilExPeerReviewGUI\editPeerReviewObject(), ilCourseContentGUI\editTimings(), ilTestPlayerAbstractGUI\endingTimeReached(), ilSurveyEvaluationGUI\evaluation(), ilSessionStatisticsGUI\exportCSV(), ilSurveyEvaluationGUI\exportEvaluationUser(), ilObjSurveyQuestionPoolGUI\exportObject(), ilObjUserFolderGUI\exportObject(), ilTestExport\exportToCSV(), ilECSSetting\fetchCertificateExpiration(), ilMailFolderTableGUI\fetchTableData(), ilCourseRegistrationGUI\fillRegistrationPeriod(), ilGroupRegistrationGUI\fillRegistrationPeriod(), ilECSServerTableGUI\fillRow(), ilBannedUsersTableGUI\fillRow(), ilTestPersonalDefaultSettingsTableGUI\fillRow(), ilSubItemSelectionTableGUI\fillRow(), ilPublicSubmissionsTableGUI\fillRow(), ilExportSelectionTableGUI\fillRow(), ilForumDraftsTableGUI\fillRow(), ilNewsForContextTableGUI\fillRow(), ilAssessmentFolderLogTableGUI\fillRow(), ilTestHistoryTableGUI\fillRow(), ilMemberExportFileTableGUI\fillRow(), ilDclExportTableGUI\fillRow(), ilHistoryTableGUI\fillRow(), ilTestPassManualScoringOverviewTableGUI\fillRow(), ilPageHistoryTableGUI\fillRow(), ilExcDeliveredFilesTableGUI\fillRow(), ilECSReleasedContentTableGUI\fillRow(), ilECSImportedContentTableGUI\fillRow(), ilAdvancedMDRecordExportFilesTableGUI\fillRow(), ilMediaCastTableGUI\fillRow(), ilLMDownloadTableGUI\fillRow(), ilCalendarInboxSharedTableGUI\fillRow(), ilSCORMTrackingUsersTableGUI\fillRow(), ilLanguageTableGUI\fillRow(), ilWikiRecentChangesTableGUI\fillRow(), ilHelpModuleTableGUI\fillRow(), ilForumPostingDraftsBlockGUI\fillRow(), ilWikiContributorsTableGUI\fillRow(), ilCalendarChangedAppointmentsTableGUI\fillRow(), ilRbacLogTableGUI\fillRow(), ilSurveyCodesTableGUI\fillRow(), ilUserLPTableGUI\fillRow(), ilSearchResultTableGUI\fillRow(), ilSurveyResultsUserTableGUI\fillRow(), ilExAssignmentTeamLogTableGUI\fillRow(), ilTestFixedParticipantsTableGUI\fillRow(), ilTestParticipantsTableGUI\fillRow(), ilExAssignmentListTextTableGUI\fillRow(), ilPollBlockGUI\fillRow(), ilSurveyMaintenanceTableGUI\fillRow(), assFileUploadFileTableGUI\fillRow(), ilGroupParticipantsTableGUI\fillRow(), ilAssignmentsTableGUI\fillRow(), ilSurveyAppraiseesTableGUI\fillRow(), ilQuestionPoolPrintViewTableGUI\fillRow(), ilExportTableGUI\fillRow(), ilPDNewsTableGUI\fillRow(), ilExAssignmentPeerReviewTableGUI\fillRow(), ilCourseParticipantsTableGUI\fillRow(), ilWikiPagesTableGUI\fillRow(), ilSubscriberTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilBadgePersonalTableGUI\fillRow(), ilAdminSubItemsTableGUI\fillRow(), ilWaitingListTableGUI\fillRow(), ilPDMailBlockGUI\fillRow(), ilPDNotesBlockGUI\fillRow(), ilLPProgressTableGUI\fillRow(), ilForumTopicTableGUI\fillRow(), ilBadgeUserTableGUI\fillRow(), ilSurveyQuestionbrowserTableGUI\fillRow(), ilSurveyQuestionsTableGUI\fillRow(), ilTrUserObjectsPropsTableGUI\fillRow(), ilCronManagerTableGUI\fillRow(), ilQuestionBrowserTableGUI\fillRow(), ilWorkspaceShareTableGUI\fillRow(), ilTrObjectUsersPropsTableGUI\fillRow(), ilTrMatrixTableGUI\fillRow(), ilBookingReservationsTableGUI\fillRow(), ilNewsForContextBlockGUI\fillRow(), ilTestQuestionBrowserTableGUI\fillRow(), ilUserTableGUI\fillRow(), ilLPProgressTableGUI\fillRowCSV(), ilBookingReservationsTableGUI\fillRowCSV(), ilTermsOfServiceAgreementByLanguageTableGUI\formatCellValue(), ilTermsOfServiceAcceptanceHistoryTableGUI\formatCellValue(), ilTestPassOverviewTableGUI\formatDate(), ilMailAttachmentTableGUI\formatValue(), ilObjTestGUI\formTimingObject(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getBaseVariablesForPreview(), ilSkillCertificateAdapter\getCertificateVariablesForPresentation(), ilScormMailTemplateLPContext\getDescription(), ilCourseMailTemplateTutorContext\getDescription(), ilExSubmission\getDownloadedFilesInfoForTableGUIS(), ilPublicUserProfileGUI\getEmbeddable(), ilPersonalSkillsGUI\getEvalItem(), ilPortfolioExerciseGUI\getExerciseInfo(), ilBlogExerciseGUI\getExerciseInfo(), ilLPTableBaseGUI\getExportMeta(), ilADTDatePresentationBridge\getHTML(), ilADTDateTimePresentationBridge\getHTML(), ilCalendarHeaderNavigationGUI\getHTML(), ilCalendarAgendaListGUI\getHTML(), ilAttendanceList\getHTML(), ilCloudPluginFileTreeGUI\getItemHtml(), ilRegistrationCodesTableGUI\getItems(), ilAccountCodesTableGUI\getItems(), ilBookingObjectsTableGUI\getItems(), ilUserTableGUI\getItems(), ilPollBlock\getMessage(), ilForumExplorerGUI\getNodeContent(), ilNoteGUI\getNoteListHTML(), ilExPeerReviewGUI\getOverviewContent(), ilExAssignmentGUI\getOverviewHeader(), ilNoteGUI\getPDNoteHTML(), ilObjSession\getPresentationTitle(), ilCourseMembershipGUI\getPrintMemberData(), ilObjForumListGUI\getProperties(), ilObjFileListGUI\getProperties(), ilTestServiceGUI\getResultsSignature(), ilDclBaseRecordModel\getStandardFieldHTML(), ilObjSCORM2004LearningModule\getTrackingDataAgg(), ilObjUserGUI\getValues(), ilTestRandomQuestionSetConfigStateMessageHandler\handle(), ilExerciseManagementGUI\handleIndividualDeadlineCallsObject(), ilLMPresentationGUI\ilPage(), ilObjCourseGUI\infoScreen(), ilObjMediaCastGUI\infoScreen(), ilObjGroupGUI\infoScreen(), ilObjSurveyGUI\infoScreen(), ilLearningProgressGUI\initCollectionManualForm(), ilAccountCodesTableGUI\initFilter(), ilRegistrationCodesTableGUI\initFilter(), ilRepositoryUserResultTableGUI\initMultiCommands(), ilPCBlogGUI\initPostingForm(), ilPCSection\insertTimings(), ilObjTest\isExecutable(), ilBadgeProfileGUI\listBackpackGroups(), ilBadgeProfileGUI\listBadges(), ilObjGroupAccess\lookupRegistrationInfo(), ilObjCourseAccess\lookupRegistrationInfo(), ilTestPlayerAbstractGUI\outProcessingTime(), ilSCGroupTableGUI\parse(), ilConsultationHourBookingTableGUI\parse(), ilSCTaskTableGUI\parse(), ilGroupParticipantsTableGUI\parse(), ilCourseParticipantsTableGUI\parse(), ilCronManagerTableGUI\parseJobToData(), ilExerciseSubmissionTableGUI\parseRow(), ilRepositoryUserResultTableGUI\parseUserIds(), ilLPTableBaseGUI\parseValue(), ilTrSummaryTableGUI\parseValue(), ilTestServiceGUI\populatePassFinishDate(), ilBlogPostingGUI\postOutputProcessing(), ilLinkCheckerTableGUI\prepareHTML(), ilWikiPageGUI\preview(), ilObjPortfolioGUI\printView(), ilObjGroupGUI\readMemberData(), ilObjCourseGUI\readMemberData(), ilSubscriberTableGUI\readSubscriberData(), ilWaitingListTableGUI\readUserData(), ilObjTestGUI\redirectToInfoScreenObject(), ilCronManagerGUI\render(), ilNewsTimelineItemGUI\render(), ilPortfolioPageGUI\renderBlogTeaser(), ilSessionStatisticsGUI\renderCurrentBasics(), ilObjBlogGUI\renderList(), ilBadgeRenderer\renderModal(), ilObjTestGUI\reviewobject(), ilPageObjectGUI\rollbackConfirmation(), ilCronManager\runActiveJobs(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilForumMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilObjExercise\sendAssignment(), ilSkillNotifications\sendMail(), ilMembershipCronNotifications\sendMail(), ilTestMailNotification\sendSimpleNotification(), ilObjSurveyGUI\sendUserResultsMail(), arIndexTableGUI\setDateFieldData(), arDisplayGUI\setDateTimeData(), ilSkillSelfEvaluationGUI\setSelfEvaluationPresentationForm(), ilObjUserFolderGUI\showActionConfirmation(), ilLPObjectStatisticsGUI\showAggregationInfo(), ilSCORM2004ScoGUI\showExportList(), ilObjSCORM2004LearningModuleGUI\showExportList(), ilObjTermsOfServiceGUI\showLastResetDate(), ilInfoScreenGUI\showLearningProgress(), ilNewsForContextBlockGUI\showNews(), ilPageObjectGUI\showPage(), ilPersonalProfileGUI\showPublicProfileFields(), ilExSubmissionFileGUI\submissionScreenObject(), ilObjTestGUI\timingOverviewObject(), ilPageObject\update(), ilObjUser\updateLogin(), ilCourseArchivesGUI\view(), ilObjFileAccessSettingsGUI\viewDiskQuotaReport(), and ilObjObjectFolderGUI\viewObject().

124  {
125  global $lng,$ilUser;
126 
127  if ($date->isNull()) {
128  return self::getLanguage()->txt('no_date');
129  }
130 
131  $has_time = !is_a($date, 'ilDate');
132 
133  // Converting pure dates to user timezone might return wrong dates
134  if ($has_time) {
135  $date_info = $date->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
136  } else {
137  $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
138  }
139 
140  if (!$a_skip_day) {
141  $sep = ", ";
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');
148  } else {
149  include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
150  $date_str = "";
151  if ($a_include_wd) {
152  $date_str = $lng->txt(self::$weekdays[$date->get(IL_CAL_FKT_DATE, 'w')]) . ", ";
153  }
154  $date_str.= $date->get(IL_CAL_FKT_DATE, 'd') . '. ' .
155  ilCalendarUtil::_numericMonthToString($date_info['mon'], false) . ' ' .
156  $date_info['year'];
157  }
158  } else {
159  $sep = "";
160  }
161 
162  if (!$has_time) {
163  return $date_str;
164  }
165 
166  switch ($ilUser->getTimeFormat()) {
168  return $date_str . $sep . $date->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone());
169 
171  return $date_str . $sep . $date->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone());
172  }
173  }
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
const IL_CAL_FKT_DATE
$ilUser
Definition: imgupload.php:18
get($a_format, $a_format_str='', $a_tz='')
get formatted date
const IL_CAL_FKT_GETDATE
global $lng
Definition: privfeed.php:17
isNull()
Check if a date is null (Datetime == '0000-00-00 00:00:00', unixtime == 0,...)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatPeriod()

static ilDatePresentation::formatPeriod ( ilDateTime  $start,
ilDateTime  $end,
  $a_skip_starting_day = false 
)
static

Format a period of two date Shows: 14.

Jul 2008 18:00 - 20:00 or: Today 18:00 - 20:00 or: 14. Jul 2008 - 16. Jul 2008 or: 14. Jul 2008, 12:00 - 16. Jul 2008, 14:00

public

Parameters

Definition at line 187 of file class.ilDatePresentation.php.

References $ilUser, ilDateTime\_equals(), ilDateTime\get(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_FKT_DATE, ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by ilChatroomHistoryGUI\__construct(), ilSessionAppointment\_appointmentToString(), ilObjectActivation\addListGUIActivationProperty(), ilCalendarEntry\appointmentToMailString(), ilObjRemoteCourseGUI\availabilityToString(), ilObjRemoteGroupGUI\availabilityToString(), ilObjRemoteTestGUI\availabilityToString(), ilCalendarAppointmentGUI\book(), ilSessionStatisticsGUI\buildData(), ilCalendarAppointmentGUI\cancelBooking(), ilECSCategoryMappingRule\conditionToString(), ilObjUser\deleteUserDefinedFieldEntries(), ilBookingObjectGUI\displayPostInfo(), ilWikiStatGUI\export(), ilCalendarChangedAppointmentsTableGUI\fillRow(), ilGroupParticipantsTableGUI\fillRow(), ilCourseParticipantsTableGUI\fillRow(), ilCalendarBlockGUI\getData(), ilCalendarAppointmentPanelGUI\getHTML(), ilCalendarAgendaListGUI\getHTML(), ilCalendarViewGUI\getModalForApp(), ilCalendarBlockGUI\getModalForApp(), ilTrQuery\getSessionData(), ilChatroomFormFactory\getSessionForm(), ilObjCourseGUI\infoScreen(), ilObjGroupGUI\infoScreen(), ilObjSessionGUI\initAttendanceList(), ilObjBookingPoolGUI\initBookingNumbersForm(), ilObjGroupAccess\lookupPeriodInfo(), ilObjCourseAccess\lookupPeriodInfo(), ilConsultationHoursTableGUI\parse(), ilAccountMail\readAccountMail(), ilAccountMail\replacePlaceholders(), ilObjBookingPoolGUI\rsvConfirmCancelAggregationForm(), ilObjBookingPoolGUI\rsvConfirmCancelObject(), ilCalendarAppointmentsTableGUI\setAppointments(), ilCalendarAppointmentGUI\showInfoScreen(), and ilMemberExport\write().

188  {
189  global $ilUser;
190 
191  $has_time = !is_a($start, 'ilDate');
192 
193  // Same day
194  if (ilDateTime::_equals($start, $end, IL_CAL_DAY, $ilUser->getTimeZone())) {
195  if (!$has_time) {
196  return self::formatDate($start);
197  } else {
198  $date_str = "";
199  $sep = "";
200  if (!$a_skip_starting_day) {
201  $date_str = self::formatDate(
202  new ilDate($start->get(IL_CAL_DATE, '', $ilUser->getTimeZone()), IL_CAL_DATE)
203  );
204  $sep = ", ";
205  }
206 
207  // $start == $end
208  if (ilDateTime::_equals($start, $end)) {
209  switch ($ilUser->getTimeFormat()) {
211  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone());
212 
214  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'h:i a', $ilUser->getTimeZone());
215  }
216  } else {
217  switch ($ilUser->getTimeFormat()) {
219  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone()) . ' - ' .
220  $end->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone());
221 
223  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone()) . ' - ' .
224  $end->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone());
225  }
226  }
227  }
228  }
229  // Different days
230  return self::formatDate($start, $a_skip_starting_day) . ' - ' . self::formatDate($end);
231  }
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Class for single dates.
const IL_CAL_FKT_DATE
$ilUser
Definition: imgupload.php:18
get($a_format, $a_format_str='', $a_tz='')
get formatted date
const IL_CAL_DATE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLanguage()

static ilDatePresentation::getLanguage ( )
static

set language

Returns

Definition at line 93 of file class.ilDatePresentation.php.

References $lang, and $lng.

Referenced by ilMailTemplateContext\resolvePlaceholder().

94  {
95  global $lng;
96 
97  return self::$lang ? self::$lang : $lng;
98  }
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ isToday()

static ilDatePresentation::isToday ( ilDateTime  $date)
static

Check if date is "today".

public

Parameters
objectilDateTime DateTime object to check
Returns
bool

Definition at line 243 of file class.ilDatePresentation.php.

References $ilUser, ilDateTime\_equals(), IL_CAL_DAY, IL_CAL_UNIX, and time.

244  {
245  global $ilUser;
246 
247  if (!is_object(self::$today)) {
248  self::$today = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
249  }
250  return ilDateTime::_equals(self::$today, $date, IL_CAL_DAY, $ilUser->getTimeZone());
251  }
const IL_CAL_UNIX
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Date and time handling
$ilUser
Definition: imgupload.php:18
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ isTomorrow()

static ilDatePresentation::isTomorrow ( ilDateTime  $date)
static

Check if date is tomorrow.

public

Parameters
objectilDateTime DateTime object to check
Returns
bool

Definition at line 281 of file class.ilDatePresentation.php.

References $ilUser, ilDateTime\_equals(), IL_CAL_DAY, IL_CAL_UNIX, ilDateTime\increment(), and time.

282  {
283  global $ilUser;
284 
285  if (!is_object(self::$tomorrow)) {
286  self::$tomorrow = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
287  self::$tomorrow->increment(IL_CAL_DAY, 1);
288  }
289 
290  return ilDateTime::_equals(self::$tomorrow, $date, IL_CAL_DAY, $ilUser->getTimeZone());
291  }
const IL_CAL_UNIX
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Date and time handling
$ilUser
Definition: imgupload.php:18
increment($a_type, $a_count=1)
increment
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ isYesterday()

static ilDatePresentation::isYesterday ( ilDateTime  $date)
static

Check if date is yesterday.

public

Parameters
objectilDateTime DateTime object to check
Returns
bool

Definition at line 261 of file class.ilDatePresentation.php.

References $ilUser, ilDateTime\_equals(), IL_CAL_DAY, IL_CAL_UNIX, ilDateTime\increment(), and time.

262  {
263  global $ilUser;
264 
265  if (!is_object(self::$yesterday)) {
266  self::$yesterday = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
267  self::$yesterday->increment(IL_CAL_DAY, -1);
268  }
269 
270  return ilDateTime::_equals(self::$yesterday, $date, IL_CAL_DAY, $ilUser->getTimeZone());
271  }
const IL_CAL_UNIX
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Date and time handling
$ilUser
Definition: imgupload.php:18
increment($a_type, $a_count=1)
increment
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ resetToDefaults()

static ilDatePresentation::resetToDefaults ( )
static

reset to defaults

Returns

Definition at line 106 of file class.ilDatePresentation.php.

References $lng.

Referenced by ilObjUser\deleteUserDefinedFieldEntries(), and ilLPProgressTableGUI\fillRowCSV().

107  {
108  global $lng;
109 
110  self::setLanguage($lng);
111  self::setUseRelativeDates(true);
112  }
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ secondsToString()

static ilDatePresentation::secondsToString (   $seconds,
  $force_with_seconds = false,
  $a_lng = null 
)
static

converts seconds to string: Long: 7 days 4 hour(s) ...

Parameters
int$secondsseconds
bool$force_with_seconds
ilLanguage$a_lng
Returns
string

Definition at line 302 of file class.ilDatePresentation.php.

References $lng, $message, and $rest.

Referenced by ilLearningProgressBaseGUI\__appendLPDetails(), ilLearningProgressBaseGUI\__appendUserInfo(), ilRegistrationMimeMailNotification\__construct(), ilCourseContentGUI\__renderItem(), ilCourseContentGUI\__renderUserItem(), ilLearningProgressBaseGUI\__showObjectDetails(), ilInfoScreenGUI\addMetaDataSections(), ilCourseContentGUI\editTimings(), ilTimingOverviewTableGUI\fillRow(), ilCalendarAppointmentsTableGUI\fillRow(), ilTrUserObjectsPropsTableGUI\fillRow(), ilCourseMailTemplateTutorContext\getDescription(), ilScormMailTemplateLPContext\getDescription(), ilObjSCORM2004LearningModule\getTrackingDataAgg(), ilObjUserFolderGUI\initFormGeneralSettings(), ilPersonalSettingsGUI\initGeneralSettingsForm(), ilLPTableBaseGUI\parseValue(), ilTrSummaryTableGUI\parseValue(), ilInfoScreenGUI\showLearningProgress(), and ilLearningProgressGUI\showtlt().

303  {
304  global $lng;
305 
306  if ($a_lng) {
307  $lng = $a_lng;
308  }
309 
310  $seconds = $seconds ? $seconds : 0;
311 
312  // #13625
313  if ($seconds > 0) {
314  $days = floor($seconds / 86400);
315  $rest = $seconds % 86400;
316 
317  $hours = floor($rest / 3600);
318  $rest = $rest % 3600;
319 
320  $minutes = floor($rest / 60);
321  $seconds = $rest % 60;
322  } else {
323  $days = ceil($seconds / 86400);
324  $rest = $seconds % 86400;
325 
326  $hours = ceil($rest / 3600);
327  $rest = $rest % 3600;
328 
329  $minutes = ceil($rest / 60);
330  $seconds = $rest % 60;
331  }
332 
333  if ($days) {
334  $message = $days . ' ' . ($days == 1 ? $lng->txt('day') : $lng->txt('days'));
335  }
336  if ($hours) {
337  if ($message) {
338  $message .= ' ';
339  }
340  $message .= ($hours . ' ' . ($hours == 1 ? $lng->txt('hour') : $lng->txt('hours')));
341  }
342  if ($minutes) {
343  if ($message) {
344  $message .= ' ';
345  }
346  $message .= ($minutes . ' ' . ($minutes == 1 ? $lng->txt('minute') : $lng->txt('minutes')));
347  }
348  if ($force_with_seconds && $seconds) {
349  if ($message) {
350  $message .= ' ';
351  }
352  $message .= ($seconds . ' ' . ($seconds == 1 ? $lng->txt('second') : $lng->txt('seconds')));
353  }
354  if (!$days and !$hours and !$minutes) {
355  return $seconds . ' ' . ($seconds == 1 ? $lng->txt('second') : $lng->txt('seconds'));
356  } else {
357  return $message;
358  }
359  }
$rest
Definition: goto.php:46
catch(Exception $e) $message
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ setLanguage()

static ilDatePresentation::setLanguage (   $a_lng)
static

set language

Returns

Definition at line 82 of file class.ilDatePresentation.php.

References $lang.

Referenced by ilObjUser\deleteUserDefinedFieldEntries(), ilMailTemplateContext\resolvePlaceholder(), ilCronDeleteInactiveUserReminderMailNotification\send(), and ilForumMailNotification\send().

83  {
84  self::$lang = $a_lng;
85  }
+ Here is the caller graph for this function:

◆ setUseRelativeDates()

static ilDatePresentation::setUseRelativeDates (   $a_status)
static

set use relative dates

Parameters
bool
Returns

Definition at line 60 of file class.ilDatePresentation.php.

Referenced by ilChatroomHistoryGUI\__construct(), ilBookingReservationsTableGUI\__construct(), ilCalendarEntry\appointmentToMailString(), ilSessionStatisticsGUI\buildData(), ilCertificate\createPreview(), ilPersonalSettingsGUI\deleteOwnAccount4(), ilObjUser\deleteUserDefinedFieldEntries(), ilBookingObjectGUI\displayPostInfo(), ilSurveyEvaluationGUI\evaluation(), ilSessionStatisticsGUI\exportCSV(), ilSurveyEvaluationGUI\exportEvaluationUser(), ilForumExportGUI\exportHTML(), ilObjectMetaDataBlockGUI\fillDataSection(), ilLMDownloadTableGUI\fillRow(), ilPollBlockGUI\fillRow(), assFileUploadFileTableGUI\fillRow(), ilQuestionPoolPrintViewTableGUI\fillRow(), ilLPProgressTableGUI\fillRowCSV(), ilTestPassOverviewTableGUI\formatDate(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getBaseVariablesForPreview(), ilSkillCertificateAdapter\getCertificateVariablesForPresentation(), ilSkillCertificateAdapter\getCertificateVariablesForPreview(), ilPersonalSkillsGUI\getEvalItem(), ilPortfolioExerciseGUI\getExerciseInfo(), ilBlogExerciseGUI\getExerciseInfo(), ilLPTableBaseGUI\getExportMeta(), ilCalendarHeaderNavigationGUI\getHTML(), ilAttendanceList\getHTML(), ilTable2GUI\getHTML(), ilObjectMetaDataGUI\getKeyValueList(), ilNoteGUI\getNoteListHTML(), ilCourseMembershipGUI\getPrintMemberData(), ilTestServiceGUI\getResultsSignature(), ilObjSurveyGUI\infoScreen(), ilObjSessionGUI\initAttendanceList(), ilPCSection\insertTimings(), ilBadgeProfileGUI\listBackpackGroups(), ilBadgeProfileGUI\listBadges(), ilCertificate\outCertificate(), ilTestServiceGUI\populatePassFinishDate(), ilBlogPostingGUI\postOutputProcessing(), ilForumExportGUI\printPost(), ilForumExportGUI\printThread(), ilObjPortfolioGUI\printView(), ilObjTestGUI\reviewobject(), ilObjBookingPoolGUI\rsvConfirmCancelAggregationForm(), ilMembershipCronNotifications\run(), ilSkillNotifications\run(), ilCronManager\runActiveJobs(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilForumMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilTestMailNotification\sendSimpleNotification(), ilSkillSelfEvaluationGUI\setSelfEvaluationPresentationForm(), ilObjTermsOfServiceGUI\showLastResetDate(), and ilMemberExport\write().

61  {
62  self::$use_relative_dates = $a_status;
63  }
+ Here is the caller graph for this function:

◆ useRelativeDates()

Field Documentation

◆ $lang

ilDatePresentation::$lang = null
staticprivate

Definition at line 38 of file class.ilDatePresentation.php.

◆ $today

ilDatePresentation::$today = null
static

Definition at line 40 of file class.ilDatePresentation.php.

◆ $tomorrow

ilDatePresentation::$tomorrow = null
static

Definition at line 41 of file class.ilDatePresentation.php.

◆ $use_relative_dates

ilDatePresentation::$use_relative_dates = true
static

Definition at line 37 of file class.ilDatePresentation.php.

◆ $weekdays

ilDatePresentation::$weekdays
staticprotected
Initial value:
0 => "Su_short",
1 => "Mo_short",
2 => "Tu_short",
3 => "We_short",
4 => "Th_short",
5 => "Fr_short",
6 => "Sa_short"
)

Definition at line 44 of file class.ilDatePresentation.php.

◆ $yesterday

ilDatePresentation::$yesterday = null
static

Definition at line 42 of file class.ilDatePresentation.php.


The documentation for this class was generated from the following file: