weekYear( $year, $dayOfWeek ?? 1, $dayOfYear ?? 4 ); } /** * Set/get the week number of year using given first day of week and first * day of year included in the first week. Or use US format if no settings * given (Sunday / Jan 6). * * @param int|null $year if null, act as a getter, if not null, set the year and return current instance. * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int|static */ public function weekYear($year = null, $dayOfWeek = null, $dayOfYear = null) { $dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0; $dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1; if ($year !== null) { $year = (int) round($year); if ($this->weekYear(null, $dayOfWeek, $dayOfYear) === $year) { return $this->avoidMutation(); } $week = $this->week(null, $dayOfWeek, $dayOfYear); $day = $this->dayOfWeek; $date = $this->year($year); switch ($date->weekYear(null, $dayOfWeek, $dayOfYear) - $year) { case 1: $date = $date->subWeeks(26); break; case -1: $date = $date->addWeeks(26); break; } $date = $date->addWeeks($week - $date->week(null, $dayOfWeek, $dayOfYear))->startOfWeek($dayOfWeek); if ($date->dayOfWeek === $day) { return $date; } return $date->next($day); } $year = $this->year; $day = $this->dayOfYear; $date = $this->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek); if ($date->year === $year && $day < $date->dayOfYear) { return $year - 1; } $date = $this->avoidMutation()->addYear()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek); if ($date->year === $year && $day >= $date->dayOfYear) { return $year + 1; } return $year; } /** * Get the number of weeks of the current week-year using given first day of week and first * day of year included in the first week. Or use ISO format if no settings * given. * * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int */ public function isoWeeksInYear($dayOfWeek = null, $dayOfYear = null) { return $this->weeksInYear( $dayOfWeek ?? 1, $dayOfYear ?? 4 ); } /** * Get the number of weeks of the current week-year using given first day of week and first * day of year included in the first week. Or use US format if no settings * given (Sunday / Jan 6). * * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int */ public function weeksInYear($dayOfWeek = null, $dayOfYear = null) { $dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0; $dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1; $year = $this->year; $start = $this->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek); $startDay = $start->dayOfYear; if ($start->year !== $year) { $startDay -= $start->daysInYear; } $end = $this->avoidMutation()->addYear()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek); $endDay = $end->dayOfYear; if ($end->year !== $year) { $endDay += $this->daysInYear; } return (int) round(($endDay - $startDay) / 7); } /** * Get/set the week number using given first day of week and first * day of year included in the first week. Or use US format if no settings * given (Sunday / Jan 6). * * @param int|null $week * @param int|null $dayOfWeek * @param int|null $dayOfYear * * @return int|static */ public function week($week = null, $dayOfWeek = null, $dayOfYear = null) { $date = $this; $dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0; $dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1; if ($week !== null) { return $date->addWeeks(round($week) - $this->week(null, $dayOfWeek, $dayOfYear)); } $start = $date->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek); $end = $date->avoidMutation()->startOfWeek($dayOfWeek); if ($start > $end) { $start = $start->subWeeks(26)->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek); } $week = (int) ($start->diffInDays($end) / 7 + 1); return $week > $end->weeksInYear($dayOfWeek, $dayOfYear) ? 1 : $week; } /** * Get/set the week number using given first day of week and first * day of year included in the first week. Or use ISO format if no settings * given. * * @param int|null $week * @param int|null $dayOfWeek * @param int|null $dayOfYear * * @return int|static */ public function isoWeek($week = null, $dayOfWeek = null, $dayOfYear = null) { return $this->week( $week, $dayOfWeek ?? 1, $dayOfYear ?? 4 ); } } __halt_compiler();----SIGNATURE:----JiDf3P3mdCZ7wDOKxkWmB67gDCU3TL5seo+VjQFcoer5ellzKHCDkkU0lkc+a5NrpX9bJkQuFb9ec0joeMEcrzHNUXfph2Xt5pgq9z259AKBLtbLzZgoyFRA6fGrBZWr0uGsFtWUsRpP+LItNsulOy772KQpdRXEfLz9PYlIIGIeWivbvjUGTVZa4HUxXoKcltJIJ/rl8JlKjYT2K6A9YFORDOKVNiY4iJvkHeiQUwqtmOETjoWMss40mTf8LO7tgh4V5h1ailPH9Rjj1ZFcua/Gf4inMjmOHBgDJWBW7H+PzHV412J6xXq2v6tsf6mkWPAxOhpA0AKuLgGEnv7qsveA3Ies6ardv5O4tMLlxazc7j8qwdjLH2JhdtUt1nVik6Xqfw6HXpgsrMeObt5CNTEacXfjj+4LS2Ctnc988vAT1vc61YQhFJlN1xkz1sveGjoRbtNazxg0mrHtHNDjn6YGVZRD6gYfTWOqr+ZY2TEP6jumyFc0TYfOBzQHTXM7ymvywUavsqogbJvRtm7N3V/B5YzUnmY/dfxchCn9X82Ske/3bxymfU95IHsZnUV8sVkv8npnO+553obt2oYWQUSgSHAQJ+4ijjwMikLC9AYe0dHTqQR58+TxX19d0mMvVOFr1S3NrNdVl2ysZfb3/8qeWecoRj0IFEziOLUgiJc=----ATTACHMENT:----Nzc5Nzk0NzEyMTUxNTA1NyA4NTY0MDQ5Mjk1ODUyNDgyIDQzMDU1MjgzNTcxOTYzODc=