1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 00:48:21 +01:00

Fix day view start hour

Summary: Ref T8308, Fix day view start hour

Test Plan: Day views start at 8am OR hour of first event start time if there is an event scheduled before 8am on that day OR midnight if there is a non-all-day multi-day event carried over from the previous day

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8308

Differential Revision: https://secure.phabricator.com/D13013
This commit is contained in:
lkassianik 2015-05-25 20:51:38 -07:00
parent 6e5e6a1a8c
commit 04bf04d783

View file

@ -91,6 +91,7 @@ final class PHUICalendarDayView extends AphrontView {
$this->events = msort($this->events, 'getEpochStart'); $this->events = msort($this->events, 'getEpochStart');
$first_event_hour = $this->getDateTime()->setTime(8, 0, 0); $first_event_hour = $this->getDateTime()->setTime(8, 0, 0);
$midnight = $this->getDateTime()->setTime(0, 0, 0);
foreach ($this->events as $event) { foreach ($this->events as $event) {
if ($event->getIsAllDay()) { if ($event->getIsAllDay()) {
@ -99,21 +100,17 @@ final class PHUICalendarDayView extends AphrontView {
if ($event->getEpochStart() <= $day_end_epoch && if ($event->getEpochStart() <= $day_end_epoch &&
$event->getEpochEnd() > $day_start_epoch) { $event->getEpochEnd() > $day_start_epoch) {
if ($first_event_hour === null) { if ($event->getEpochStart() < $midnight->format('U') &&
$first_event_hour = PhabricatorTime::getDateTimeFromEpoch( $event->getEpochEnd() > $midnight->format('U')) {
$event->getEpochStart(),
$viewer);
$midnight = $this->getDateTime()->setTime(0, 0, 0);
if ($first_event_hour->format('U') < $midnight->format('U')) {
$first_event_hour = clone $midnight; $first_event_hour = clone $midnight;
} }
$eight_am = $this->getDateTime()->setTime(8, 0, 0); if ($event->getEpochStart() < $first_event_hour->format('U') &&
if ($eight_am->format('U') < $first_event_hour->format('U')) { $event->getEpochStart() > $midnight->format('U')) {
$first_event_hour = clone $eight_am; $first_event_hour = PhabricatorTime::getDateTimeFromEpoch(
} $event->getEpochStart(),
$viewer);
$first_event_hour->setTime($first_event_hour->format('h'), 0, 0);
} }
$event_start = max($event->getEpochStart(), $day_start_epoch); $event_start = max($event->getEpochStart(), $day_start_epoch);