@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Leading and trailing days should be considered part of the month in month view.

Summary: Closes T8177, Leading and trailing days should be considered part of the month in month view.

Test Plan: Open month view, no days should be empty unless they don't have events. Modify query, make sure month view still obeys query.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8177

Differential Revision: https://secure.phabricator.com/D12834

+55 -13
+22
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
··· 76 76 $display_start = $start_day->format('U'); 77 77 $display_end = $next->format('U'); 78 78 79 + // 0 = Sunday is always the start of the week, for now 80 + $start_of_week = 0; 81 + $end_of_week = 6 - $start_of_week; 82 + 83 + $first_of_month = $start_day->format('w'); 84 + $last_of_month = id(clone $next)->modify('-1 day')->format('w'); 85 + 79 86 if (!$min_range || ($min_range < $display_start)) { 80 87 $min_range = $display_start; 88 + 89 + if ($this->isMonthView($saved) && 90 + $first_of_month > $start_of_week) { 91 + $min_range = id(clone $start_day) 92 + ->modify('-'.$first_of_month.' days') 93 + ->format('U'); 94 + } 81 95 } 82 96 if (!$max_range || ($max_range > $display_end)) { 83 97 $max_range = $display_end; 98 + 99 + if ($this->isMonthView($saved) && 100 + $last_of_month < $end_of_week) { 101 + $max_range = id(clone $next) 102 + ->modify('+'.(6 - $first_of_month).' days') 103 + ->format('U'); 104 + } 105 + 84 106 } 85 107 } 86 108
+33 -13
src/view/phui/calendar/PHUICalendarMonthView.php
··· 56 56 } 57 57 58 58 $events = msort($this->events, 'getEpochStart'); 59 - 60 59 $days = $this->getDatesInMonth(); 61 - 62 - require_celerity_resource('phui-calendar-month-css'); 63 - 64 - $first = reset($days); 65 - $empty = $first->format('w'); 66 60 67 61 $cell_lists = array(); 68 62 $empty_cell = array( ··· 72 66 'count' => 0, 73 67 'class' => null, 74 68 ); 69 + 70 + require_celerity_resource('phui-calendar-month-css'); 71 + 72 + $first = reset($days); 73 + $start_of_week = 0; 74 + 75 + $empty = $first->format('w'); 75 76 76 77 for ($ii = 0; $ii < $empty; $ii++) { 77 78 $cell_lists[] = $empty_cell; ··· 409 410 $month = $this->month; 410 411 $year = $this->year; 411 412 412 - // Get the year and month numbers of the following month, so we can 413 - // determine when this month ends. 414 413 list($next_year, $next_month) = $this->getNextYearAndMonth(); 414 + $end_date = new DateTime("{$next_year}-{$next_month}-01", $timezone); 415 415 416 - $end_date = new DateTime("{$next_year}-{$next_month}-01", $timezone); 417 - $end_epoch = $end_date->format('U'); 416 + $start_of_week = 0; 417 + $end_of_week = 6 - $start_of_week; 418 + $days_in_month = id(clone $end_date)->modify('-1 day')->format('d'); 419 + 420 + $first_month_day_date = new DateTime("{$year}-{$month}-01", $timezone); 421 + $last_month_day_date = id(clone $end_date)->modify('-1 day'); 422 + 423 + $first_weekday_of_month = $first_month_day_date->format('w'); 424 + $last_weekday_of_month = $last_month_day_date->format('w'); 425 + 426 + $num_days_display = $days_in_month; 427 + if ($start_of_week < $first_weekday_of_month) { 428 + $num_days_display += $first_weekday_of_month; 429 + } 430 + if ($end_of_week > $last_weekday_of_month) { 431 + $num_days_display += (6 - $last_weekday_of_month); 432 + $end_date->modify('+'.(6 - $last_weekday_of_month).' days'); 433 + } 418 434 419 435 $days = array(); 420 - for ($day = 1; $day <= 31; $day++) { 421 - $day_date = new DateTime("{$year}-{$month}-{$day}", $timezone); 436 + $day_date = id(clone $first_month_day_date) 437 + ->modify('-'.$first_weekday_of_month.' days'); 438 + 439 + for ($day = 1; $day <= $num_days_display; $day++) { 422 440 $day_epoch = $day_date->format('U'); 441 + $end_epoch = $end_date->format('U'); 423 442 if ($day_epoch >= $end_epoch) { 424 443 break; 425 444 } else { 426 - $days[] = $day_date; 445 + $days[] = clone $day_date; 427 446 } 447 + $day_date->modify('+1 day'); 428 448 } 429 449 430 450 return $days;