From 40714bb0eccc3f4c66b41b2c3569220f34ab66b7 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Mon, 22 Jun 2015 18:44:08 -0700 Subject: [PATCH] Formatting event dates in list view Summary: Closes T8639, Formatting event dates in list view Test Plan: List view should show dates in wide and narrow lists. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8639 Differential Revision: https://secure.phabricator.com/D13398 --- .../PhabricatorCalendarEventSearchEngine.php | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php index 20a848f988..9cd5a9fd34 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -264,11 +264,11 @@ final class PhabricatorCalendarEventSearchEngine $list = new PHUIObjectItemListView(); foreach ($events as $event) { - $from = phabricator_datetime($event->getDateFrom(), $viewer); $duration = ''; + $event_date_info = $this->getEventDateLabel($event); $creator_handle = $handles[$event->getUserPHID()]; - $attendees = array(); + foreach ($event->getInvitees() as $invitee) { $attendees[] = $invitee->getInviteePHID(); } @@ -287,8 +287,8 @@ final class PhabricatorCalendarEventSearchEngine $item = id(new PHUIObjectItemView()) ->setHeader($viewer->renderHandle($event->getPHID())->render()) + ->addAttribute($event_date_info) ->addAttribute($attendees) - ->addIcon('none', $from) ->addIcon('none', $duration); $list->addItem($item); @@ -509,4 +509,41 @@ final class PhabricatorCalendarEventSearchEngine return false; } + + private function getEventDateLabel($event) { + $viewer = $this->requireViewer(); + + $from_datetime = PhabricatorTime::getDateTimeFromEpoch( + $event->getDateFrom(), + $viewer); + $to_datetime = PhabricatorTime::getDateTimeFromEpoch( + $event->getDateTo(), + $viewer); + + $from_date_formatted = $from_datetime->format('Y m d'); + $to_date_formatted = $to_datetime->format('Y m d'); + + if ($event->getIsAllDay()) { + if ($from_date_formatted == $to_date_formatted) { + return pht( + '%s, All Day', + phabricator_date($event->getDateFrom(), $viewer)); + } else { + return pht( + '%s - %s, All Day', + phabricator_date($event->getDateFrom(), $viewer), + phabricator_date($event->getDateTo(), $viewer)); + } + } else if ($from_date_formatted == $to_date_formatted) { + return pht( + '%s - %s', + phabricator_datetime($event->getDateFrom(), $viewer), + phabricator_time($event->getDateTo(), $viewer)); + } else { + return pht( + '%s - %s', + phabricator_datetime($event->getDateFrom(), $viewer), + phabricator_datetime($event->getDateTo(), $viewer)); + } + } }