From d016309defc0fc83cecee65b9b4c5a1a81161f66 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Sun, 2 Jun 2013 11:35:16 -0700 Subject: [PATCH] Conpherence - fix calendar bugs part deux Summary: I needed to port my extremely clever "last sunday as of tomorrow" trick to the display layer. Also found a fun bug in testing where +N days was changing it to 1:00 AM from 00:00 AM with my timezone configuration. Presumably all sorts of whacky hyjinx ensue when you modify DateTime and you need to re-specify the timezone after to get it to work Test Plan: verified that Today, SUNDAY, we see TODAY -> Saturday and it all looks good. Verified midnite -> just before midnight status events span but a single day. Reviewers: epriestley, chad Reviewed By: chad CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6114 --- .../controller/ConpherenceWidgetController.php | 14 ++++++++++---- .../conpherence/query/ConpherenceThreadQuery.php | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/applications/conpherence/controller/ConpherenceWidgetController.php b/src/applications/conpherence/controller/ConpherenceWidgetController.php index bd83d3cd29..673a3b3425 100644 --- a/src/applications/conpherence/controller/ConpherenceWidgetController.php +++ b/src/applications/conpherence/controller/ConpherenceWidgetController.php @@ -243,7 +243,6 @@ final class ConpherenceWidgetController extends $week_day_number = $day->format('w'); - $day->setTime(0, 0, 0); $epoch_start = $day->format('U'); $next_day = clone $day; $next_day->modify('+1 day'); @@ -325,7 +324,7 @@ final class ConpherenceWidgetController extends } if ($is_today || ($calendar_columns && $calendar_columns < 3)) { $active_class = ''; - if ($day->format('Ymd') == $today->format('Ymd')) { + if ($is_today) { $active_class = '-active'; } $inner_layout = array(); @@ -383,11 +382,18 @@ final class ConpherenceWidgetController extends $user = $this->getRequest()->getUser(); $timezone = new DateTimeZone($user->getTimezoneIdentifier()); - $first_day = new DateTime('last sunday', $timezone); + $start_epoch = phabricator_format_local_time( + strtotime('last sunday', strtotime('tomorrow')), + $user, + 'U'); + $first_day = new DateTime('@'.$start_epoch, $timezone); $timestamps = array(); for ($day = 0; $day < 9; $day++) { $timestamp = clone $first_day; - $timestamps[] = $timestamp->modify(sprintf('+%d days', $day)); + $timestamp->modify(sprintf('+%d days', $day)); + // set the timezone again 'cuz DateTime is weird + $timestamp->setTimeZone($timezone); + $timestamps[] = $timestamp; } return array( 'today' => new DateTime('today', $timezone), diff --git a/src/applications/conpherence/query/ConpherenceThreadQuery.php b/src/applications/conpherence/query/ConpherenceThreadQuery.php index 5b20dbd89e..0df5a770df 100644 --- a/src/applications/conpherence/query/ConpherenceThreadQuery.php +++ b/src/applications/conpherence/query/ConpherenceThreadQuery.php @@ -218,8 +218,8 @@ final class ConpherenceThreadQuery // statuses of everyone currently in the conpherence // we show sunday -> saturday in a list *AND* a window - // of today -> +2 days. If its saturday we need - // +2 days. + // of today -> +2 days. Ergo, if its saturday we need + // +2 days, for +9 days total. $start_epoch = phabricator_format_local_time( strtotime('last sunday', strtotime('tomorrow')), $this->getViewer(),