1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

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
This commit is contained in:
Bob Trahan 2013-06-02 11:35:16 -07:00
parent 06338db5bb
commit d016309def
2 changed files with 12 additions and 6 deletions

View file

@ -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),

View file

@ -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(),