From a527d6c340d0d30e1df1271181bd90c2db2217cf Mon Sep 17 00:00:00 2001 From: lkassianik Date: Sun, 17 May 2015 16:37:21 -0700 Subject: [PATCH] Month view header should display month name of the month completely shown, not leading or trailing month. Summary: Fixes T8229, Month view header should display month name of the month completely shown, not leading or trailing month. Test Plan: Open month view for May. Month view header should be May, not April. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8229 Differential Revision: https://secure.phabricator.com/D12887 --- src/view/phui/calendar/PHUICalendarMonthView.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php index df692d271d..806ecad719 100644 --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -62,8 +62,6 @@ final class PHUICalendarMonthView extends AphrontView { require_celerity_resource('phui-calendar-month-css'); - $first = reset($days); - foreach ($days as $day) { $day_number = $day->format('j'); @@ -144,7 +142,7 @@ final class PHUICalendarMonthView extends AphrontView { $warnings = $this->getQueryRangeWarning(); $box = id(new PHUIObjectBoxView()) - ->setHeader($this->renderCalendarHeader($first)) + ->setHeader($this->renderCalendarHeader($this->getDateTime())) ->appendChild($table) ->setFormErrors($warnings); if ($this->error) { @@ -469,6 +467,7 @@ final class PHUICalendarMonthView extends AphrontView { $year = $this->year; list($next_year, $next_month) = $this->getNextYearAndMonth(); + $end_date = new DateTime("{$next_year}-{$next_month}-01", $timezone); list($start_of_week, $end_of_week) = $this->getWeekStartAndEnd(); @@ -481,12 +480,14 @@ final class PHUICalendarMonthView extends AphrontView { $first_weekday_of_month = $first_month_day_date->format('w'); $last_weekday_of_month = $last_month_day_date->format('w'); + $day_date = id(clone $first_month_day_date); + $num_days_display = $days_in_month; if ($start_of_week !== $first_weekday_of_month) { $interim_start_num = ($first_weekday_of_month + 7 - $start_of_week) % 7; $num_days_display += $interim_start_num; - $day_date = id(clone $first_month_day_date) - ->modify('-'.$interim_start_num.' days'); + + $day_date->modify('-'.$interim_start_num.' days'); } if ($end_of_week !== $last_weekday_of_month) { $interim_end_day_num = ($end_of_week - $last_weekday_of_month + 7) % 7;