ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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, $include_seconds=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,
  $include_seconds = false 
)
static

Format a date public.

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

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

References $DIC, $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(), 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\addSubmission(), ilObjBookingPoolGUI\buildDatesBySchedule(), ilParticipantsTestResultsTableGUI\buildFormattedAccessDate(), ilTestParticipantsTableGUI\buildFormattedAccessDate(), ilParticipantsTestResultsTableGUI\buildPassFinishedString(), ilTestParticipantsTimeExtensionGUI\buildTimingForm(), ilObjSurvey\canStartSurvey(), ilAppointmentPresentationConsultationHoursGUI\collectPropertiesAndActions(), ilConsultationHoursGUI\confirmDelete(), ilMemberExportGUI\confirmDeleteExportFile(), ilSCORM2004ScoGUI\confirmDeleteExportFile(), ilObjSCORM2004LearningModuleGUI\confirmDeleteExportFile(), ilObjSurveyQuestionPoolGUI\confirmDeleteExportFileObject(), ilMailFolderGUI\confirmDeleteMails(), ilObjLanguageFolderGUI\confirmRefreshSelectedObject(), ilCalendarAppointmentGUI\confirmRegister(), ilConsultationHoursGUI\confirmRejectBooking(), ilCalendarAppointmentGUI\confirmUnregister(), ilForum\convertDate(), ilForumMailNotification\createMailDate(), 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(), ilForumDraftsTableGUI\fillRow(), ilBannedUsersTableGUI\fillRow(), ilECSServerTableGUI\fillRow(), ilTestPersonalDefaultSettingsTableGUI\fillRow(), ilSubItemSelectionTableGUI\fillRow(), ilPublicSubmissionsTableGUI\fillRow(), ilNewsForContextTableGUI\fillRow(), ilExportSelectionTableGUI\fillRow(), ilAssessmentFolderLogTableGUI\fillRow(), ilTestHistoryTableGUI\fillRow(), ilMemberExportFileTableGUI\fillRow(), ilDclExportTableGUI\fillRow(), ilHistoryTableGUI\fillRow(), ilPageHistoryTableGUI\fillRow(), ilTestPassManualScoringOverviewTableGUI\fillRow(), ilExcDeliveredFilesTableGUI\fillRow(), ilECSReleasedContentTableGUI\fillRow(), ilAdvancedMDRecordExportFilesTableGUI\fillRow(), ilECSImportedContentTableGUI\fillRow(), ilMediaCastTableGUI\fillRow(), ilLMDownloadTableGUI\fillRow(), ilCalendarInboxSharedTableGUI\fillRow(), ilLanguageTableGUI\fillRow(), ilForumPostingDraftsBlockGUI\fillRow(), ilWikiRecentChangesTableGUI\fillRow(), ilSCORMTrackingUsersTableGUI\fillRow(), ilHelpModuleTableGUI\fillRow(), ilWikiContributorsTableGUI\fillRow(), ilFileVersionsTableGUI\fillRow(), ilCalendarChangedAppointmentsTableGUI\fillRow(), ilSurveyCodesTableGUI\fillRow(), ilSurveyResultsUserTableGUI\fillRow(), ilExAssignmentTeamLogTableGUI\fillRow(), ilRbacLogTableGUI\fillRow(), ilPollBlockGUI\fillRow(), ilUserLPTableGUI\fillRow(), ilSearchResultTableGUI\fillRow(), ilExAssignmentListTextTableGUI\fillRow(), ilSurveyMaintenanceTableGUI\fillRow(), ilAssignmentsTableGUI\fillRow(), assFileUploadFileTableGUI\fillRow(), ilSurveyAppraiseesTableGUI\fillRow(), ilGroupParticipantsTableGUI\fillRow(), ilQuestionPoolPrintViewTableGUI\fillRow(), ilExportTableGUI\fillRow(), ilPDNewsTableGUI\fillRow(), ilExAssignmentPeerReviewTableGUI\fillRow(), ilWikiPagesTableGUI\fillRow(), ilCourseParticipantsTableGUI\fillRow(), ilBadgePersonalTableGUI\fillRow(), ilWebResourceEditableLinkTableGUI\fillRow(), ilAdminSubItemsTableGUI\fillRow(), ilPDMailBlockGUI\fillRow(), ilSubscriberTableGUI\fillRow(), ilWaitingListTableGUI\fillRow(), ilPDNotesBlockGUI\fillRow(), ilLPProgressTableGUI\fillRow(), ilForumTopicTableGUI\fillRow(), ilBadgeUserTableGUI\fillRow(), ilSurveyQuestionbrowserTableGUI\fillRow(), ilSurveyQuestionsTableGUI\fillRow(), ilTrUserObjectsPropsTableGUI\fillRow(), ilCronManagerTableGUI\fillRow(), ilWorkspaceShareTableGUI\fillRow(), ilTrObjectUsersPropsTableGUI\fillRow(), ilQuestionBrowserTableGUI\fillRow(), ilTrMatrixTableGUI\fillRow(), ilTestQuestionBrowserTableGUI\fillRow(), ilNewsForContextBlockGUI\fillRow(), ilBookingReservationsTableGUI\fillRow(), ilUserTableGUI\fillRow(), ilLPProgressTableGUI\fillRowCSV(), ilBookingReservationsTableGUI\fillRowCSV(), ilCertificateDateHelper\formatDate(), ilTestPassOverviewTableGUI\formatDate(), ilCertificateDateHelper\formatDateTime(), ilMailAttachmentTableGUI\formatValue(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getBaseVariablesForPreview(), ilPageObjectGUI\getBlockingInfoMessage(), ilSkillCertificateAdapter\getCertificateVariablesForPresentation(), ilScormMailTemplateLPContext\getDescription(), ilCourseMailTemplateTutorContext\getDescription(), ilExSubmission\getDownloadedFilesInfoForTableGUIS(), ilPublicUserProfileGUI\getEmbeddable(), ilPersonalSkillsGUI\getEvalItem(), ilBlogExerciseGUI\getExerciseInfo(), ilPortfolioExerciseGUI\getExerciseInfo(), ilLPTableBaseGUI\getExportMeta(), ilIndividualAssessmentMembersTableGUI\getGradedInformations(), 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(), ilNoteGUI\getPDNoteHTML(), ilObjSession\getPresentationTitle(), ilCourseMembershipGUI\getPrintMemberData(), ilObjForumListGUI\getProperties(), ilObjFileListGUI\getProperties(), ilExerciseManagementGUI\getReportPanel(), ilTermsOfServiceDocumentGUI\getResetMessageBoxHtml(), ilTestServiceGUI\getResultsSignature(), ilDclBaseRecordModel\getStandardFieldHTML(), ilExcAssMemberState\getTimePresentation(), ilObjSCORM2004LearningModule\getTrackingDataAgg(), ilObjUserGUI\getValues(), ilTestRandomQuestionSetConfigStateMessageHandler\handle(), ilExerciseManagementGUI\handleIndividualDeadlineCallsObject(), ilLMPresentationGUI\ilPage(), ilObjCourseGUI\infoScreen(), ilObjMediaCastGUI\infoScreen(), ilObjGroupGUI\infoScreen(), ilObjSurveyGUI\infoScreen(), ilLearningProgressGUI\initCollectionManualForm(), ilAccountCodesTableGUI\initFilter(), ilRegistrationCodesTableGUI\initFilter(), ilPCVerificationGUI\initForm(), ilRepositoryUserResultTableGUI\initMultiCommands(), ilPCBlogGUI\initPostingForm(), ilPCSection\insertTimings(), ilObjTest\isExecutable(), ilBadgeProfileGUI\listBackpackGroups(), ilBadgeProfileGUI\listBadges(), ilUserCertificateGUI\listCertificates(), ilObjGroupAccess\lookupRegistrationInfo(), ilObjCourseAccess\lookupRegistrationInfo(), ilTestPlayerAbstractGUI\outProcessingTime(), ilSCGroupTableGUI\parse(), ilConsultationHourBookingTableGUI\parse(), ilSCTaskTableGUI\parse(), ilGroupParticipantsTableGUI\parse(), ilCourseParticipantsTableGUI\parse(), ilCronManagerTableGUI\parseJobToData(), ilMembershipCronNotifications\parseNewsItem(), ilExerciseSubmissionTableGUI\parseRow(), ilRepositoryUserResultTableGUI\parseUserIds(), ilLPTableBaseGUI\parseValue(), ilTrSummaryTableGUI\parseValue(), ilTestServiceGUI\populatePassFinishDate(), ilBlogPostingGUI\postOutputProcessing(), ilLinkCheckerTableGUI\prepareHTML(), ilWikiPageGUI\preview(), ilObjPortfolioGUI\printView(), ilLearningSequenceRoles\readMemberData(), ilObjGroupGUI\readMemberData(), ilObjCourseGUI\readMemberData(), ilSubscriberTableGUI\readSubscriberData(), ilWaitingListTableGUI\readUserData(), ilObjTestGUI\redirectToInfoScreenObject(), ilCronManagerGUI\render(), ilNewsTimelineItemGUI\render(), ilPortfolioPageGUI\renderBlogTeaser(), ilSessionStatisticsGUI\renderCurrentBasics(), ilObjBlogGUI\renderList(), ilBadgeRenderer\renderModal(), ilLikeGUI\renderModal(), ilObjTestGUI\reviewobject(), ilPageObjectGUI\rollbackConfirmation(), ilCronManager\runActiveJobs(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilObjExercise\sendAssignment(), ilSkillNotifications\sendMail(), ilMembershipCronNotifications\sendMail(), ilBookCronNotification\sendMails(), ilTestMailNotification\sendSimpleNotification(), ilObjSurveyGUI\sendUserResultsMail(), arIndexTableGUI\setDateFieldData(), arDisplayGUI\setDateTimeData(), ilSkillSelfEvaluationGUI\setSelfEvaluationPresentationForm(), ilObjUserFolderGUI\showActionConfirmation(), ilLPObjectStatisticsGUI\showAggregationInfo(), ilSCORM2004ScoGUI\showExportList(), ilObjSCORM2004LearningModuleGUI\showExportList(), ilInfoScreenGUI\showLearningProgress(), ilTestParticipantsTimeExtensionGUI\showListCmd(), ilChatroomHistoryGUI\showMessages(), ilNewsForContextBlockGUI\showNews(), ilTestResultsGUI\showNoResultsReportingMessage(), ilPageObjectGUI\showPage(), ilPersonalProfileGUI\showPublicProfileFields(), ilExSubmissionFileGUI\submissionScreenObject(), ilPageObject\update(), ilObjUser\updateLogin(), ilObjFileAccessSettingsGUI\viewDiskQuotaReport(), and ilObjObjectFolderGUI\viewObject().

129  {
130  global $DIC;
131 
132  $lng = $DIC['lng'];
133  $ilUser = $DIC['ilUser'];
134 
135  if ($date->isNull()) {
136  return self::getLanguage()->txt('no_date');
137  }
138 
139  $has_time = !is_a($date, 'ilDate');
140 
141  // Converting pure dates to user timezone might return wrong dates
142  if ($has_time) {
143  $date_info = $date->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
144  } else {
145  $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
146  }
147 
148  if (!$a_skip_day) {
149  $sep = ", ";
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');
156  } else {
157  include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
158  $date_str = "";
159  if ($a_include_wd) {
160  $date_str = $lng->txt(self::$weekdays[$date->get(IL_CAL_FKT_DATE, 'w')]) . ", ";
161  }
162  $date_str .= $date->get(IL_CAL_FKT_DATE, 'd') . '. ' .
163  ilCalendarUtil::_numericMonthToString($date_info['mon'], false) . ' ' .
164  $date_info['year'];
165  }
166  } else {
167  $sep = "";
168  }
169 
170  if (!$has_time) {
171  return $date_str;
172  }
173 
174  $sec = ($include_seconds)
175  ? ":s"
176  : "";
177 
178  switch ($ilUser->getTimeFormat()) {
180  return $date_str . $sep . $date->get(IL_CAL_FKT_DATE, 'H:i'.$sec, $ilUser->getTimeZone());
181 
183  return $date_str . $sep . $date->get(IL_CAL_FKT_DATE, 'g:ia'.$sec, $ilUser->getTimeZone());
184  }
185  }
global $DIC
Definition: saml.php:7
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
$lng
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
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 199 of file class.ilDatePresentation.php.

References $DIC, $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 ilSessionAppointment\_appointmentToString(), ilAccountMail\addAttachments(), ilObjectActivation\addListGUIActivationProperty(), ilCalendarEntry\appointmentToMailString(), ilObjRemoteTestGUI\availabilityToString(), ilObjRemoteCourseGUI\availabilityToString(), ilObjRemoteGroupGUI\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(), ilObjSession\getPresentationTitleAppointmentPeriod(), ilTrQuery\getSessionData(), ilChatroomFormFactory\getSessionForm(), ilObjCourseGUI\infoScreen(), ilObjGroupGUI\infoScreen(), ilObjSessionGUI\initAttendanceList(), ilObjBookingPoolGUI\initBookingNumbersForm(), ilObjGroupAccess\lookupPeriodInfo(), ilObjCourseAccess\lookupPeriodInfo(), ilConsultationHoursTableGUI\parse(), ilAccountMail\replacePlaceholders(), ilObjBookingPoolGUI\rsvConfirmCancelAggregationForm(), ilObjBookingPoolGUI\rsvConfirmCancelObject(), ilObjBookingPoolGUI\rsvConfirmDeleteObject(), ilCalendarAppointmentsTableGUI\setAppointments(), ilCalendarAppointmentGUI\showInfoScreen(), ilChatroomHistoryGUI\showMessages(), and ilMemberExport\write().

200  {
201  global $DIC;
202 
203  $ilUser = $DIC['ilUser'];
204 
205  $has_time = !is_a($start, 'ilDate');
206 
207  // Same day
208  if (ilDateTime::_equals($start, $end, IL_CAL_DAY, $ilUser->getTimeZone())) {
209  if (!$has_time) {
210  return self::formatDate($start);
211  } else {
212  $date_str = "";
213  $sep = "";
214  if (!$a_skip_starting_day) {
215  $date_str = self::formatDate(
216  new ilDate($start->get(IL_CAL_DATE, '', $ilUser->getTimeZone()), IL_CAL_DATE)
217  );
218  $sep = ", ";
219  }
220 
221  // $start == $end
222  if (ilDateTime::_equals($start, $end)) {
223  switch ($ilUser->getTimeFormat()) {
225  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone());
226 
228  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'h:i a', $ilUser->getTimeZone());
229  }
230  } else {
231  switch ($ilUser->getTimeFormat()) {
233  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone()) . ' - ' .
234  $end->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone());
235 
237  return $date_str . $sep . $start->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone()) . ' - ' .
238  $end->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone());
239  }
240  }
241  }
242  }
243  // Different days
244  return self::formatDate($start, $a_skip_starting_day) . ' - ' . self::formatDate($end);
245  }
global $DIC
Definition: saml.php:7
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 $DIC, $lang, and $lng.

Referenced by ilMailTemplateContext\resolvePlaceholder().

94  {
95  global $DIC;
96 
97  $lng = $DIC['lng'];
98 
99  return self::$lang ? self::$lang : $lng;
100  }
global $DIC
Definition: saml.php:7
$lng
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
+ 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 257 of file class.ilDatePresentation.php.

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

258  {
259  global $DIC;
260 
261  $ilUser = $DIC['ilUser'];
262 
263  if (!is_object(self::$today)) {
264  self::$today = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
265  }
266  return ilDateTime::_equals(self::$today, $date, IL_CAL_DAY, $ilUser->getTimeZone());
267  }
global $DIC
Definition: saml.php:7
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
+ 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 299 of file class.ilDatePresentation.php.

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

300  {
301  global $DIC;
302 
303  $ilUser = $DIC['ilUser'];
304 
305  if (!is_object(self::$tomorrow)) {
306  self::$tomorrow = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
307  self::$tomorrow->increment(IL_CAL_DAY, 1);
308  }
309 
310  return ilDateTime::_equals(self::$tomorrow, $date, IL_CAL_DAY, $ilUser->getTimeZone());
311  }
global $DIC
Definition: saml.php:7
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
+ 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 277 of file class.ilDatePresentation.php.

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

278  {
279  global $DIC;
280 
281  $ilUser = $DIC['ilUser'];
282 
283  if (!is_object(self::$yesterday)) {
284  self::$yesterday = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
285  self::$yesterday->increment(IL_CAL_DAY, -1);
286  }
287 
288  return ilDateTime::_equals(self::$yesterday, $date, IL_CAL_DAY, $ilUser->getTimeZone());
289  }
global $DIC
Definition: saml.php:7
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
+ Here is the call graph for this function:

◆ resetToDefaults()

static ilDatePresentation::resetToDefaults ( )
static

reset to defaults

Returns

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

References $DIC, and $lng.

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

109  {
110  global $DIC;
111 
112  $lng = $DIC['lng'];
113 
114  self::setLanguage($lng);
115  self::setUseRelativeDates(true);
116  }
global $DIC
Definition: saml.php:7
$lng
+ 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 322 of file class.ilDatePresentation.php.

References $DIC, $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(), ilScormMailTemplateLPContext\getDescription(), ilCourseMailTemplateTutorContext\getDescription(), ilObjSCORM2004LearningModule\getTrackingDataAgg(), ilObjUserFolderGUI\initFormGeneralSettings(), ilPersonalSettingsGUI\initGeneralSettingsForm(), ilLPTableBaseGUI\parseValue(), ilTrSummaryTableGUI\parseValue(), ilInfoScreenGUI\showLearningProgress(), and ilLearningProgressGUI\showtlt().

323  {
324  global $DIC;
325 
326  $lng = $DIC['lng'];
327 
328  if ($a_lng) {
329  $lng = $a_lng;
330  }
331 
332  $seconds = $seconds ? $seconds : 0;
333 
334  // #13625
335  if ($seconds > 0) {
336  $days = floor($seconds / 86400);
337  $rest = $seconds % 86400;
338 
339  $hours = floor($rest / 3600);
340  $rest = $rest % 3600;
341 
342  $minutes = floor($rest / 60);
343  $seconds = $rest % 60;
344  } else {
345  $days = ceil($seconds / 86400);
346  $rest = $seconds % 86400;
347 
348  $hours = ceil($rest / 3600);
349  $rest = $rest % 3600;
350 
351  $minutes = ceil($rest / 60);
352  $seconds = $rest % 60;
353  }
354 
355  if ($days) {
356  $message = $days . ' ' . ($days == 1 ? $lng->txt('day') : $lng->txt('days'));
357  }
358  if ($hours) {
359  if ($message) {
360  $message .= ' ';
361  }
362  $message .= ($hours . ' ' . ($hours == 1 ? $lng->txt('hour') : $lng->txt('hours')));
363  }
364  if ($minutes) {
365  if ($message) {
366  $message .= ' ';
367  }
368  $message .= ($minutes . ' ' . ($minutes == 1 ? $lng->txt('minute') : $lng->txt('minutes')));
369  }
370  if ($force_with_seconds && $seconds) {
371  if ($message) {
372  $message .= ' ';
373  }
374  $message .= ($seconds . ' ' . ($seconds == 1 ? $lng->txt('second') : $lng->txt('seconds')));
375  }
376  if (!$days and !$hours and !$minutes) {
377  return $seconds . ' ' . ($seconds == 1 ? $lng->txt('second') : $lng->txt('seconds'));
378  } else {
379  return $message;
380  }
381  }
$rest
Definition: goto.php:46
global $DIC
Definition: saml.php:7
catch(Exception $e) $message
$lng
+ 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 ilForumMailNotification\createMailDate(), ilObjUser\deleteUserDefinedFieldEntries(), ilMailTemplateContext\resolvePlaceholder(), ilCronDeleteInactiveUserReminderMailNotification\send(), and ilForumMailNotification\send().

83  {
84  self::$lang = $a_lng;
85  }
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
+ 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 ilBookingReservationsTableGUI\__construct(), ilCalendarEntry\appointmentToMailString(), ilSessionStatisticsGUI\buildData(), 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(), ilCertificateDateHelper\formatDate(), ilTestPassOverviewTableGUI\formatDate(), ilCertificateDateHelper\formatDateTime(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getBaseVariablesForPreview(), ilSkillCertificateAdapter\getCertificateVariablesForPresentation(), ilSkillCertificateAdapter\getCertificateVariablesForPreview(), ilPersonalSkillsGUI\getEvalItem(), ilBlogExerciseGUI\getExerciseInfo(), ilPortfolioExerciseGUI\getExerciseInfo(), ilLPTableBaseGUI\getExportMeta(), ilCalendarHeaderNavigationGUI\getHTML(), ilAttendanceList\getHTML(), ilTable2GUI\getHTML(), ilObjectMetaDataGUI\getKeyValueList(), ilNoteGUI\getNoteListHTML(), ilCourseMembershipGUI\getPrintMemberData(), ilTermsOfServiceDocumentGUI\getResetMessageBoxHtml(), ilTestServiceGUI\getResultsSignature(), ilObjSurveyGUI\infoScreen(), ilObjSessionGUI\initAttendanceList(), ilPCSection\insertTimings(), ilBadgeProfileGUI\listBackpackGroups(), ilBadgeProfileGUI\listBadges(), ilUserCertificateGUI\listCertificates(), ilTestServiceGUI\populatePassFinishDate(), ilBlogPostingGUI\postOutputProcessing(), ilWikiPageGUI\preview(), 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(), ilChatroomHistoryGUI\showMessages(), 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:
= array(
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: