1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

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
This commit is contained in:
lkassianik 2015-05-17 16:37:21 -07:00
parent 427cc22149
commit a527d6c340

View file

@ -62,8 +62,6 @@ final class PHUICalendarMonthView extends AphrontView {
require_celerity_resource('phui-calendar-month-css'); require_celerity_resource('phui-calendar-month-css');
$first = reset($days);
foreach ($days as $day) { foreach ($days as $day) {
$day_number = $day->format('j'); $day_number = $day->format('j');
@ -144,7 +142,7 @@ final class PHUICalendarMonthView extends AphrontView {
$warnings = $this->getQueryRangeWarning(); $warnings = $this->getQueryRangeWarning();
$box = id(new PHUIObjectBoxView()) $box = id(new PHUIObjectBoxView())
->setHeader($this->renderCalendarHeader($first)) ->setHeader($this->renderCalendarHeader($this->getDateTime()))
->appendChild($table) ->appendChild($table)
->setFormErrors($warnings); ->setFormErrors($warnings);
if ($this->error) { if ($this->error) {
@ -469,6 +467,7 @@ final class PHUICalendarMonthView extends AphrontView {
$year = $this->year; $year = $this->year;
list($next_year, $next_month) = $this->getNextYearAndMonth(); list($next_year, $next_month) = $this->getNextYearAndMonth();
$end_date = new DateTime("{$next_year}-{$next_month}-01", $timezone); $end_date = new DateTime("{$next_year}-{$next_month}-01", $timezone);
list($start_of_week, $end_of_week) = $this->getWeekStartAndEnd(); 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'); $first_weekday_of_month = $first_month_day_date->format('w');
$last_weekday_of_month = $last_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; $num_days_display = $days_in_month;
if ($start_of_week !== $first_weekday_of_month) { if ($start_of_week !== $first_weekday_of_month) {
$interim_start_num = ($first_weekday_of_month + 7 - $start_of_week) % 7; $interim_start_num = ($first_weekday_of_month + 7 - $start_of_week) % 7;
$num_days_display += $interim_start_num; $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) { if ($end_of_week !== $last_weekday_of_month) {
$interim_end_day_num = ($end_of_week - $last_weekday_of_month + 7) % 7; $interim_end_day_num = ($end_of_week - $last_weekday_of_month + 7) % 7;