PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.1
Independent Analytics – WordPress Analytics Plugin v2.15.1
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / nesbot / carbon / src / Carbon / Traits / Week.php
independent-analytics / vendor / nesbot / carbon / src / Carbon / Traits Last commit date
Boundaries.php 2 years ago Cast.php 2 years ago Comparison.php 1 year ago Converter.php 2 years ago Creator.php 2 years ago Date.php 1 month ago DeprecatedProperties.php 2 years ago Difference.php 2 years ago IntervalRounding.php 2 years ago IntervalStep.php 2 years ago Localization.php 1 month ago Macro.php 2 years ago MagicParameter.php 2 years ago Mixin.php 2 years ago Modifiers.php 2 years ago Mutability.php 2 years ago ObjectInitialisation.php 2 years ago Options.php 1 year ago Rounding.php 2 years ago Serialization.php 2 years ago Test.php 1 month ago Timestamp.php 1 month ago ToStringFormat.php 2 years ago Units.php 2 years ago Week.php 2 years ago
Week.php
187 lines
1 <?php
2
3 /**
4 * This file is part of the Carbon package.
5 *
6 * (c) Brian Nesbitt <brian@nesbot.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace IAWPSCOPED\Carbon\Traits;
12
13 /**
14 * Trait Week.
15 *
16 * week and ISO week number, year and count in year.
17 *
18 * Depends on the following properties:
19 *
20 * @property int $daysInYear
21 * @property int $dayOfWeek
22 * @property int $dayOfYear
23 * @property int $year
24 *
25 * Depends on the following methods:
26 *
27 * @method static addWeeks(int $weeks = 1)
28 * @method static copy()
29 * @method static dayOfYear(int $dayOfYear)
30 * @method string getTranslationMessage(string $key, ?string $locale = null, ?string $default = null, $translator = null)
31 * @method static next(int|string $day = null)
32 * @method static startOfWeek(int $day = 1)
33 * @method static subWeeks(int $weeks = 1)
34 * @method static year(int $year = null)
35 * @internal
36 */
37 trait Week
38 {
39 /**
40 * Set/get the week number of year using given first day of week and first
41 * day of year included in the first week. Or use ISO format if no settings
42 * given.
43 *
44 * @param int|null $year if null, act as a getter, if not null, set the year and return current instance.
45 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday)
46 * @param int|null $dayOfYear first day of year included in the week #1
47 *
48 * @return int|static
49 */
50 public function isoWeekYear($year = null, $dayOfWeek = null, $dayOfYear = null)
51 {
52 return $this->weekYear($year, $dayOfWeek ?? 1, $dayOfYear ?? 4);
53 }
54 /**
55 * Set/get the week number of year using given first day of week and first
56 * day of year included in the first week. Or use US format if no settings
57 * given (Sunday / Jan 6).
58 *
59 * @param int|null $year if null, act as a getter, if not null, set the year and return current instance.
60 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday)
61 * @param int|null $dayOfYear first day of year included in the week #1
62 *
63 * @return int|static
64 */
65 public function weekYear($year = null, $dayOfWeek = null, $dayOfYear = null)
66 {
67 $dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0;
68 $dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1;
69 if ($year !== null) {
70 $year = (int) \round($year);
71 if ($this->weekYear(null, $dayOfWeek, $dayOfYear) === $year) {
72 return $this->avoidMutation();
73 }
74 $week = $this->week(null, $dayOfWeek, $dayOfYear);
75 $day = $this->dayOfWeek;
76 $date = $this->year($year);
77 switch ($date->weekYear(null, $dayOfWeek, $dayOfYear) - $year) {
78 case 1:
79 $date = $date->subWeeks(26);
80 break;
81 case -1:
82 $date = $date->addWeeks(26);
83 break;
84 }
85 $date = $date->addWeeks($week - $date->week(null, $dayOfWeek, $dayOfYear))->startOfWeek($dayOfWeek);
86 if ($date->dayOfWeek === $day) {
87 return $date;
88 }
89 return $date->next($day);
90 }
91 $year = $this->year;
92 $day = $this->dayOfYear;
93 $date = $this->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
94 if ($date->year === $year && $day < $date->dayOfYear) {
95 return $year - 1;
96 }
97 $date = $this->avoidMutation()->addYear()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
98 if ($date->year === $year && $day >= $date->dayOfYear) {
99 return $year + 1;
100 }
101 return $year;
102 }
103 /**
104 * Get the number of weeks of the current week-year using given first day of week and first
105 * day of year included in the first week. Or use ISO format if no settings
106 * given.
107 *
108 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday)
109 * @param int|null $dayOfYear first day of year included in the week #1
110 *
111 * @return int
112 */
113 public function isoWeeksInYear($dayOfWeek = null, $dayOfYear = null)
114 {
115 return $this->weeksInYear($dayOfWeek ?? 1, $dayOfYear ?? 4);
116 }
117 /**
118 * Get the number of weeks of the current week-year using given first day of week and first
119 * day of year included in the first week. Or use US format if no settings
120 * given (Sunday / Jan 6).
121 *
122 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday)
123 * @param int|null $dayOfYear first day of year included in the week #1
124 *
125 * @return int
126 */
127 public function weeksInYear($dayOfWeek = null, $dayOfYear = null)
128 {
129 $dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0;
130 $dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1;
131 $year = $this->year;
132 $start = $this->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
133 $startDay = $start->dayOfYear;
134 if ($start->year !== $year) {
135 $startDay -= $start->daysInYear;
136 }
137 $end = $this->avoidMutation()->addYear()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
138 $endDay = $end->dayOfYear;
139 if ($end->year !== $year) {
140 $endDay += $this->daysInYear;
141 }
142 return (int) \round(($endDay - $startDay) / 7);
143 }
144 /**
145 * Get/set the week number using given first day of week and first
146 * day of year included in the first week. Or use US format if no settings
147 * given (Sunday / Jan 6).
148 *
149 * @param int|null $week
150 * @param int|null $dayOfWeek
151 * @param int|null $dayOfYear
152 *
153 * @return int|static
154 */
155 public function week($week = null, $dayOfWeek = null, $dayOfYear = null)
156 {
157 $date = $this;
158 $dayOfWeek = $dayOfWeek ?? $this->getTranslationMessage('first_day_of_week') ?? 0;
159 $dayOfYear = $dayOfYear ?? $this->getTranslationMessage('day_of_first_week_of_year') ?? 1;
160 if ($week !== null) {
161 return $date->addWeeks(\round($week) - $this->week(null, $dayOfWeek, $dayOfYear));
162 }
163 $start = $date->avoidMutation()->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
164 $end = $date->avoidMutation()->startOfWeek($dayOfWeek);
165 if ($start > $end) {
166 $start = $start->subWeeks(26)->dayOfYear($dayOfYear)->startOfWeek($dayOfWeek);
167 }
168 $week = (int) ($start->diffInDays($end) / 7 + 1);
169 return $week > $end->weeksInYear($dayOfWeek, $dayOfYear) ? 1 : $week;
170 }
171 /**
172 * Get/set the week number using given first day of week and first
173 * day of year included in the first week. Or use ISO format if no settings
174 * given.
175 *
176 * @param int|null $week
177 * @param int|null $dayOfWeek
178 * @param int|null $dayOfYear
179 *
180 * @return int|static
181 */
182 public function isoWeek($week = null, $dayOfWeek = null, $dayOfYear = null)
183 {
184 return $this->week($week, $dayOfWeek ?? 1, $dayOfYear ?? 4);
185 }
186 }
187