1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

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
This commit is contained in:
vrana 2012-06-28 10:24:33 -07:00
parent 38e029205b
commit 7227d7d850

View file

@ -72,6 +72,8 @@ final class AphrontCalendarMonthView extends AphrontView {
$show_events = array(); $show_events = array();
foreach ($days as $day) { foreach ($days as $day) {
$day_number = $day->format('j');
$holiday = idx($this->holidays, $day->format('Y-m-d')); $holiday = idx($this->holidays, $day->format('Y-m-d'));
$class = 'aphront-calendar-day'; $class = 'aphront-calendar-day';
$weekday = $day->format('w'); $weekday = $day->format('w');
@ -82,7 +84,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$day->setTime(0, 0, 0); $day->setTime(0, 0, 0);
$epoch_start = $day->format('U'); $epoch_start = $day->format('U');
$day->setTime(24, 0, 0); $day->modify('+1 day');
$epoch_end = $day->format('U'); $epoch_end = $day->format('U');
if ($weekday == 0) { if ($weekday == 0) {
@ -104,7 +106,6 @@ final class AphrontCalendarMonthView extends AphrontView {
$event->getEpochEnd() > $epoch_start) { $event->getEpochEnd() > $epoch_start) {
$show_events[$event->getUserPHID()] = $this->renderEvent( $show_events[$event->getUserPHID()] = $this->renderEvent(
$event, $event,
$day,
$epoch_start, $epoch_start,
$epoch_end); $epoch_end);
} }
@ -122,7 +123,7 @@ final class AphrontCalendarMonthView extends AphrontView {
$markup[] = $markup[] =
'<div class="'.$class.'">'. '<div class="'.$class.'">'.
'<div class="aphront-calendar-date-number">'. '<div class="aphront-calendar-date-number">'.
$day->format('j'). $day_number.
'</div>'. '</div>'.
$holiday_markup. $holiday_markup.
implode("\n", $show_events). implode("\n", $show_events).
@ -203,7 +204,6 @@ final class AphrontCalendarMonthView extends AphrontView {
private function renderEvent( private function renderEvent(
AphrontCalendarEventView $event, AphrontCalendarEventView $event,
DateTime $day,
$epoch_start, $epoch_start,
$epoch_end) { $epoch_end) {