From c79623f756dd20e6299bda65a60c71c29d360208 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 24 Feb 2014 20:21:28 -0800 Subject: [PATCH] Add allday, multiday logic to AphrontEventView Summary: Hardens up the logic for DST and makes them easier to access elsewhere. Test Plan: view sample events, all day and multiday, in my sandbox Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D8332 --- .../calendar/view/AphrontCalendarEventView.php | 16 ++++++++++++++++ src/view/phui/calendar/PHUICalendarListView.php | 11 ++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/applications/calendar/view/AphrontCalendarEventView.php b/src/applications/calendar/view/AphrontCalendarEventView.php index f82c89faea..6ab2b9d8e1 100644 --- a/src/applications/calendar/view/AphrontCalendarEventView.php +++ b/src/applications/calendar/view/AphrontCalendarEventView.php @@ -71,6 +71,22 @@ final class AphrontCalendarEventView extends AphrontView { } } + public function getAllDay() { + $time = (60 * 60 * 22); + if (($this->getEpochEnd() - $this->getEpochStart()) >= $time) { + return true; + } + return false; + } + + public function getMultiDay() { + $nextday = strtotime('12:00 AM Tomorrow', $this->getEpochStart()); + if ($this->getEpochEnd() > $nextday) { + return true; + } + return false; + } + public function render() { throw new Exception("Events are only rendered indirectly."); } diff --git a/src/view/phui/calendar/PHUICalendarListView.php b/src/view/phui/calendar/PHUICalendarListView.php index 9aa1bf16c9..70761ba063 100644 --- a/src/view/phui/calendar/PHUICalendarListView.php +++ b/src/view/phui/calendar/PHUICalendarListView.php @@ -32,16 +32,12 @@ final class PHUICalendarListView extends AphrontTagView { $events = msort($this->events, 'getEpochStart'); - // All Day Event (well, 23 hours, 59 minutes worth) - $timespan = ((3600 * 24) - 60); - $singletons = array(); $allday = false; foreach ($events as $event) { $color = $event->getColor(); - $length = ($event->getEpochEnd() - $event->getEpochStart()); - if ($length >= $timespan) { + if ($event->getAllDay()) { $timelabel = pht('All Day'); } else { $timelabel = phabricator_time( @@ -99,10 +95,7 @@ final class PHUICalendarListView extends AphrontTagView { Javelin::initBehavior('phabricator-tooltips'); - // Multiple Days - $timespan = ((3600 * 24) + 60); - $length = ($event->getEpochEnd() - $event->getEpochStart()); - if ($length >= $timespan) { + if ($event->getMultiDay()) { $tip = pht('%s, Until: %s', $event->getName(), phabricator_date($event->getEpochEnd(), $this->getUser())); } else {