diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -122,7 +122,7 @@ 'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894', 'rsrc/css/phui/calendar/phui-calendar-day.css' => '3b4a65d8', 'rsrc/css/phui/calendar/phui-calendar-list.css' => '840baa8d', - 'rsrc/css/phui/calendar/phui-calendar-month.css' => '7819a8b1', + 'rsrc/css/phui/calendar/phui-calendar-month.css' => '4fba442e', 'rsrc/css/phui/calendar/phui-calendar.css' => '8345be98', 'rsrc/css/phui/phui-action-header-view.css' => '89c497e7', 'rsrc/css/phui/phui-action-list.css' => '4f4d09f2', @@ -763,7 +763,7 @@ 'phui-calendar-css' => '8345be98', 'phui-calendar-day-css' => '3b4a65d8', 'phui-calendar-list-css' => '840baa8d', - 'phui-calendar-month-css' => '7819a8b1', + 'phui-calendar-month-css' => '4fba442e', 'phui-crumbs-view-css' => '594d719e', 'phui-document-view-css' => '94d5dcd8', 'phui-feed-story-css' => 'c9f3a0b5', diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -228,6 +228,15 @@ $today_class = 'phui-calendar-today-slot'; } + if ($this->isDateInCurrentWeek($date)) { + $today_class .= ' phui-calendar-this-week'; + } + + $last_week_day = 6; + if ($date->format('w') == $last_week_day) { + $today_class .= ' last-weekday'; + } + $today_slot = phutil_tag ( 'div', array( @@ -254,6 +263,16 @@ $cell_div); } + private function isDateInCurrentWeek($date) { + list($week_start_date, $week_end_date) = $this->getThisWeekRange(); + + if ($date->format('U') < $week_end_date->format('U') && + $date->format('U') >= $week_start_date->format('U')) { + return true; + } + return false; + } + private function getEventCountBadge($count, $viewer_is_invited) { $class = 'phui-calendar-month-count-badge'; @@ -484,6 +503,34 @@ return $days; } + private function getTodayMidnight() { + $viewer = $this->getUser(); + $today = new DateTime('@'.time()); + $today->setTimeZone($viewer->getTimeZone()); + $today->setTime(0, 0, 0); + + return $today; + } + + private function getThisWeekRange() { + $week_start = 0; + $week_end = 6; + + $today = $this->getTodayMidnight(); + $date_weekday = $today->format('w'); + + $days_from_week_start = $date_weekday - $week_start; + $days_to_week_end = $week_end - $date_weekday + 1; + + $modify = '-'.$days_from_week_start.' days'; + $week_start_date = id(clone $today)->modify($modify); + + $modify = '+'.$days_to_week_end.' days'; + $week_end_date = id(clone $today)->modify($modify); + + return array($week_start_date, $week_end_date); + } + private function getDateTime() { $user = $this->user; $timezone = new DateTimeZone($user->getTimezoneIdentifier()); diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-month.css b/webroot/rsrc/css/phui/calendar/phui-calendar-month.css --- a/webroot/rsrc/css/phui/calendar/phui-calendar-month.css +++ b/webroot/rsrc/css/phui/calendar/phui-calendar-month.css @@ -96,7 +96,7 @@ table.phui-calendar-view a.phui-calendar-date-number { color: {$lightgreytext}; - padding: 0 4px; + padding: 4px; display: inline-block; min-width: 16px; text-align: center; @@ -111,10 +111,19 @@ .phui-calendar-today-slot { display: block; - width: 100%; height: 4px; - padding: 0; - margin: 0; + position: absolute; + left: 0; + right: -1px; + bottom: 0; +} + +.phui-calendar-today-slot.last-weekday { + right: 0px; +} + +.phui-calendar-today-slot.phui-calendar-this-week { + background-color: {$blueborder}; } .phui-calendar-today-slot.phui-calendar-today {