Code Duplication    Length = 3-3 lines in 6 locations

code/abstract/CalendarAbstractWeekView.php 2 locations

@@ 344-346 (lines=3) @@
341
        // 1) Research of the week
342
343
        $firstDate = mktime(0, 0, 0, 1, 1, $year);
344
        while (date('W', $firstDate) != 1) {
345
            $firstDate = mktime(0, 0, 0, date('n', $firstDate), date('j', $firstDate) + 1, date('Y', $firstDate));
346
        }
347
        while (date('W', $firstDate) < $week) {
348
            $firstDate = mktime(0, 0, 0, date('n', $firstDate), date('j', $firstDate) + 7, date('Y', $firstDate));
349
        }
@@ 347-349 (lines=3) @@
344
        while (date('W', $firstDate) != 1) {
345
            $firstDate = mktime(0, 0, 0, date('n', $firstDate), date('j', $firstDate) + 1, date('Y', $firstDate));
346
        }
347
        while (date('W', $firstDate) < $week) {
348
            $firstDate = mktime(0, 0, 0, date('n', $firstDate), date('j', $firstDate) + 7, date('Y', $firstDate));
349
        }
350
351
        // 2) Research of the first day of the week
352

code/views/CalendarMonthView.php 1 location

@@ 125-127 (lines=3) @@
122
123
        while (date('Y', $weekFirstDate) < $year || (date('Y', $weekFirstDate) == $year && date('n', $weekFirstDate) <= $month)) {
124
            $weekMonday = $weekFirstDate;
125
            while (date('N', $weekMonday) != 1) {
126
                $weekMonday = mktime(0, 0, 0, date('n', $weekMonday), date('j', $weekMonday) + 1, date('Y', $weekMonday));
127
            }
128
            $week = date('W', $weekMonday);
129
            $yearOfWeek = date('Y', $weekMonday);
130
            if ($month == 1) {

code/views/CalendarWeekView.php 3 locations

@@ 58-60 (lines=3) @@
55
        
56
        $lastDate = $this->getWeekStartDay($day, $month, $year);
57
        
58
        while (date('N', $lastDate) != $this->dayStart) {
59
            $lastDate = mktime(0, 0, 0, date('n', $lastDate), date('j', $lastDate) - 1, date('Y', $lastDate));
60
        }
61
        while (in_array(date('N', $lastDate), $this->daysRemoved)) {
62
            $lastDate = mktime(0, 0, 0, date('n', $lastDate), date('j', $lastDate) + 1, date('Y', $lastDate));
63
        }
@@ 61-63 (lines=3) @@
58
        while (date('N', $lastDate) != $this->dayStart) {
59
            $lastDate = mktime(0, 0, 0, date('n', $lastDate), date('j', $lastDate) - 1, date('Y', $lastDate));
60
        }
61
        while (in_array(date('N', $lastDate), $this->daysRemoved)) {
62
            $lastDate = mktime(0, 0, 0, date('n', $lastDate), date('j', $lastDate) + 1, date('Y', $lastDate));
63
        }
64
        
65
        for ($i = 0; $i < $this->number; $i++) {
66
            $datesGroup = array();
@@ 159-161 (lines=3) @@
156
    {
157
        $date = mktime(0, 0, 0, $month, $day, $year);
158
        
159
        while (date('N', $date) > 1) { // It means that the 1st day of this week is not Monday
160
            $date = mktime(0, 0, 0, date('n', $date), date('j', $date) - 1, date('Y', $date));
161
        }
162
        
163
        return $date;
164
    }