From 7227d7d85029d2eacf6fafaf97b9c30cbf17bc27 Mon Sep 17 00:00:00 2001 From: vrana Date: Thu, 28 Jun 2012 10:24:33 -0700 Subject: [PATCH] Fix displaying day numbers in calendar Summary: They were shifted by one because of calling `$day->setTime(24, 0, 0)`. I've tried to clone the date and get the epoch from the clone but it was crashing for some reason. Test Plan: /calendar/ Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D2882 --- .../calendar/view/AphrontCalendarMonthView.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/applications/calendar/view/AphrontCalendarMonthView.php b/src/applications/calendar/view/AphrontCalendarMonthView.php index 7134757bc5..b95eff44c0 100644 --- a/src/applications/calendar/view/AphrontCalendarMonthView.php +++ b/src/applications/calendar/view/AphrontCalendarMonthView.php @@ -72,6 +72,8 @@ final class AphrontCalendarMonthView extends AphrontView { $show_events = array(); foreach ($days as $day) { + $day_number = $day->format('j'); + $holiday = idx($this->holidays, $day->format('Y-m-d')); $class = 'aphront-calendar-day'; $weekday = $day->format('w'); @@ -82,7 +84,7 @@ final class AphrontCalendarMonthView extends AphrontView { $day->setTime(0, 0, 0); $epoch_start = $day->format('U'); - $day->setTime(24, 0, 0); + $day->modify('+1 day'); $epoch_end = $day->format('U'); if ($weekday == 0) { @@ -104,7 +106,6 @@ final class AphrontCalendarMonthView extends AphrontView { $event->getEpochEnd() > $epoch_start) { $show_events[$event->getUserPHID()] = $this->renderEvent( $event, - $day, $epoch_start, $epoch_end); } @@ -122,7 +123,7 @@ final class AphrontCalendarMonthView extends AphrontView { $markup[] = '
'. '
'. - $day->format('j'). + $day_number. '
'. $holiday_markup. implode("\n", $show_events). @@ -203,7 +204,6 @@ final class AphrontCalendarMonthView extends AphrontView { private function renderEvent( AphrontCalendarEventView $event, - DateTime $day, $epoch_start, $epoch_end) {