1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

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
This commit is contained in:
Chad Little 2014-02-24 20:21:28 -08:00
parent d19e2155be
commit c79623f756
2 changed files with 18 additions and 9 deletions

View file

@ -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() { public function render() {
throw new Exception("Events are only rendered indirectly."); throw new Exception("Events are only rendered indirectly.");
} }

View file

@ -32,16 +32,12 @@ final class PHUICalendarListView extends AphrontTagView {
$events = msort($this->events, 'getEpochStart'); $events = msort($this->events, 'getEpochStart');
// All Day Event (well, 23 hours, 59 minutes worth)
$timespan = ((3600 * 24) - 60);
$singletons = array(); $singletons = array();
$allday = false; $allday = false;
foreach ($events as $event) { foreach ($events as $event) {
$color = $event->getColor(); $color = $event->getColor();
$length = ($event->getEpochEnd() - $event->getEpochStart()); if ($event->getAllDay()) {
if ($length >= $timespan) {
$timelabel = pht('All Day'); $timelabel = pht('All Day');
} else { } else {
$timelabel = phabricator_time( $timelabel = phabricator_time(
@ -99,10 +95,7 @@ final class PHUICalendarListView extends AphrontTagView {
Javelin::initBehavior('phabricator-tooltips'); Javelin::initBehavior('phabricator-tooltips');
// Multiple Days if ($event->getMultiDay()) {
$timespan = ((3600 * 24) + 60);
$length = ($event->getEpochEnd() - $event->getEpochStart());
if ($length >= $timespan) {
$tip = pht('%s, Until: %s', $event->getName(), $tip = pht('%s, Until: %s', $event->getName(),
phabricator_date($event->getEpochEnd(), $this->getUser())); phabricator_date($event->getEpochEnd(), $this->getUser()));
} else { } else {