/**
  * Renders string content for the conversation subject and either the description or latest conversation comment
  * if it exists.
  * @param Conversation $conversation
  * @return string
  */
 public static function renderSubjectAndLatestForDisplayView(Conversation $conversation)
 {
     $url = Yii::app()->createUrl('/conversations/default/details', array('id' => $conversation->id));
     $content = $conversation->subject;
     $details = ZurmoHtml::tag('span', array('class' => 'list-item-details'), DateTimeUtil::getTimeSinceDisplayContent($conversation->latestDateTime));
     $link = ZurmoHtml::link($content, $url);
     return $link . $details;
 }
 /**
  * Get feed information if projects for user
  * @param ProjectAuditEvent $projectAuditEvent
  * @return string
  */
 public static function getFeedInformationForDashboard(ProjectAuditEvent $projectAuditEvent)
 {
     assert('$projectAuditEvent instanceof ProjectAuditEvent');
     $project = Project::getById(intval($projectAuditEvent->project->id));
     $dateTime = DateTimeUtil::getTimeSinceDisplayContent($projectAuditEvent->dateTime);
     $data = array('{timeSpanLabel}' => $dateTime);
     if (ActionSecurityUtil::canCurrentUserPerformAction('Details', $project)) {
         $projectName = static::resolveProjectName($project);
         $data['{projectname}'] = $projectName;
         $user = User::getById($projectAuditEvent->user->id);
         $data['{username}'] = $user->getFullName();
         $unserializedData = unserialize($projectAuditEvent->serializedData);
         if (is_array($unserializedData)) {
             $data = array_merge($unserializedData, $data);
         }
     } else {
         return Zurmo::t('ProjectsModule', '<strong>Activity on a restricted project
                                                </strong> <small>about {timeSpanLabel}</small>', $data);
     }
     return static::getMessageContentByEventAndData($projectAuditEvent->eventName, $data);
 }
 public function testTimeDifference()
 {
     $time = date("Y-m-d H:i:s", strtotime('-5 hours', time()));
     $timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
     $this->assertEquals('5 hours ago', $timeDiff);
     $time = date("Y-m-d H:i:s", strtotime('-5 days', time()));
     $timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
     $this->assertEquals('5 days ago', $timeDiff);
     $time = date("Y-m-d H:i:s", strtotime('-5 minutes', time()));
     $timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
     $this->assertEquals('5 minutes ago', $timeDiff);
     $time = date("Y-m-d H:i:s", strtotime('-5 seconds', time()));
     $timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
     $this->assertEquals('5 seconds ago', $timeDiff);
 }
 /**
  * @param Notification $notification
  * @return string
  */
 public static function renderListViewContent(Notification $notification)
 {
     $content = strval($notification);
     if ($content != null) {
         $content = '<b>' . $content . '</b>';
     }
     if ($notification->notificationMessage->id > 0) {
         if ($notification->notificationMessage->htmlContent != null) {
             $content .= ZurmoHtml::wrapLabel(Yii::app()->format->raw($notification->notificationMessage->htmlContent), "last-comment");
         } elseif ($notification->notificationMessage->textContent != null) {
             $content .= ZurmoHtml::wrapLabel(Yii::app()->format->text($notification->notificationMessage->textContent), "last-comment");
         }
     }
     $content .= ZurmoHtml::tag('span', array('class' => 'list-item-details'), DateTimeUtil::getTimeSinceDisplayContent($notification->createdDateTime));
     return $content;
 }
 public function testGetTimeSinceDisplayContent()
 {
     //30 minutes ago
     $timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 30 * 60);
     $timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
     $this->assertEquals($timeSinceLastestUpdate, '0 hours ago');
     //58 minutes ago
     $timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 58 * 60);
     $timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
     $this->assertEquals($timeSinceLastestUpdate, '0 hours ago');
     //61 minutes ago
     $timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 61 * 60);
     $timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
     $this->assertEquals($timeSinceLastestUpdate, '1 hour ago');
     //3 hours ago
     $timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 3 * 60 * 60);
     $timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
     $this->assertEquals($timeSinceLastestUpdate, '3 hours ago');
     //27 hours ago
     $timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 27 * 60 * 60);
     $timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
     $this->assertEquals($timeSinceLastestUpdate, '1 day ago');
     //10 days ago
     $timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 10 * 24 * 60 * 60);
     $timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
     $this->assertEquals($timeSinceLastestUpdate, '10 days ago');
 }
 public function getModelCreationTimeContent(RedBeanModel $model)
 {
     return DateTimeUtil::getTimeSinceDisplayContent($model->createdDateTime);
 }