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:
parent
38e029205b
commit
7227d7d850
1 changed files with 4 additions and 4 deletions
|
@ -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[] =
|
||||
'<div class="'.$class.'">'.
|
||||
'<div class="aphront-calendar-date-number">'.
|
||||
$day->format('j').
|
||||
$day_number.
|
||||
'</div>'.
|
||||
$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) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue