1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

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
This commit is contained in:
lkassianik 2015-06-22 18:44:08 -07:00
parent 4be568d346
commit 40714bb0ec

View file

@ -264,11 +264,11 @@ final class PhabricatorCalendarEventSearchEngine
$list = new PHUIObjectItemListView(); $list = new PHUIObjectItemListView();
foreach ($events as $event) { foreach ($events as $event) {
$from = phabricator_datetime($event->getDateFrom(), $viewer);
$duration = ''; $duration = '';
$event_date_info = $this->getEventDateLabel($event);
$creator_handle = $handles[$event->getUserPHID()]; $creator_handle = $handles[$event->getUserPHID()];
$attendees = array(); $attendees = array();
foreach ($event->getInvitees() as $invitee) { foreach ($event->getInvitees() as $invitee) {
$attendees[] = $invitee->getInviteePHID(); $attendees[] = $invitee->getInviteePHID();
} }
@ -287,8 +287,8 @@ final class PhabricatorCalendarEventSearchEngine
$item = id(new PHUIObjectItemView()) $item = id(new PHUIObjectItemView())
->setHeader($viewer->renderHandle($event->getPHID())->render()) ->setHeader($viewer->renderHandle($event->getPHID())->render())
->addAttribute($event_date_info)
->addAttribute($attendees) ->addAttribute($attendees)
->addIcon('none', $from)
->addIcon('none', $duration); ->addIcon('none', $duration);
$list->addItem($item); $list->addItem($item);
@ -509,4 +509,41 @@ final class PhabricatorCalendarEventSearchEngine
return false; 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));
}
}
} }