PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.5
Independent Analytics – WordPress Analytics Plugin v2.15.5
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 / Boundaries.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
Boundaries.php
411 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 use IAWPSCOPED\Carbon\Exceptions\UnknownUnitException;
14 /**
15 * Trait Boundaries.
16 *
17 * startOf, endOf and derived method for each unit.
18 *
19 * Depends on the following properties:
20 *
21 * @property int $year
22 * @property int $month
23 * @property int $daysInMonth
24 * @property int $quarter
25 *
26 * Depends on the following methods:
27 *
28 * @method $this setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0)
29 * @method $this setDate(int $year, int $month, int $day)
30 * @method $this addMonths(int $value = 1)
31 * @internal
32 */
33 trait Boundaries
34 {
35 /**
36 * Resets the time to 00:00:00 start of day
37 *
38 * @example
39 * ```
40 * echo Carbon::parse('2018-07-25 12:45:16')->startOfDay();
41 * ```
42 *
43 * @return static
44 */
45 public function startOfDay()
46 {
47 return $this->setTime(0, 0, 0, 0);
48 }
49 /**
50 * Resets the time to 23:59:59.999999 end of day
51 *
52 * @example
53 * ```
54 * echo Carbon::parse('2018-07-25 12:45:16')->endOfDay();
55 * ```
56 *
57 * @return static
58 */
59 public function endOfDay()
60 {
61 return $this->setTime(static::HOURS_PER_DAY - 1, static::MINUTES_PER_HOUR - 1, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
62 }
63 /**
64 * Resets the date to the first day of the month and the time to 00:00:00
65 *
66 * @example
67 * ```
68 * echo Carbon::parse('2018-07-25 12:45:16')->startOfMonth();
69 * ```
70 *
71 * @return static
72 */
73 public function startOfMonth()
74 {
75 return $this->setDate($this->year, $this->month, 1)->startOfDay();
76 }
77 /**
78 * Resets the date to end of the month and time to 23:59:59.999999
79 *
80 * @example
81 * ```
82 * echo Carbon::parse('2018-07-25 12:45:16')->endOfMonth();
83 * ```
84 *
85 * @return static
86 */
87 public function endOfMonth()
88 {
89 return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay();
90 }
91 /**
92 * Resets the date to the first day of the quarter and the time to 00:00:00
93 *
94 * @example
95 * ```
96 * echo Carbon::parse('2018-07-25 12:45:16')->startOfQuarter();
97 * ```
98 *
99 * @return static
100 */
101 public function startOfQuarter()
102 {
103 $month = ($this->quarter - 1) * static::MONTHS_PER_QUARTER + 1;
104 return $this->setDate($this->year, $month, 1)->startOfDay();
105 }
106 /**
107 * Resets the date to end of the quarter and time to 23:59:59.999999
108 *
109 * @example
110 * ```
111 * echo Carbon::parse('2018-07-25 12:45:16')->endOfQuarter();
112 * ```
113 *
114 * @return static
115 */
116 public function endOfQuarter()
117 {
118 return $this->startOfQuarter()->addMonths(static::MONTHS_PER_QUARTER - 1)->endOfMonth();
119 }
120 /**
121 * Resets the date to the first day of the year and the time to 00:00:00
122 *
123 * @example
124 * ```
125 * echo Carbon::parse('2018-07-25 12:45:16')->startOfYear();
126 * ```
127 *
128 * @return static
129 */
130 public function startOfYear()
131 {
132 return $this->setDate($this->year, 1, 1)->startOfDay();
133 }
134 /**
135 * Resets the date to end of the year and time to 23:59:59.999999
136 *
137 * @example
138 * ```
139 * echo Carbon::parse('2018-07-25 12:45:16')->endOfYear();
140 * ```
141 *
142 * @return static
143 */
144 public function endOfYear()
145 {
146 return $this->setDate($this->year, 12, 31)->endOfDay();
147 }
148 /**
149 * Resets the date to the first day of the decade and the time to 00:00:00
150 *
151 * @example
152 * ```
153 * echo Carbon::parse('2018-07-25 12:45:16')->startOfDecade();
154 * ```
155 *
156 * @return static
157 */
158 public function startOfDecade()
159 {
160 $year = $this->year - $this->year % static::YEARS_PER_DECADE;
161 return $this->setDate($year, 1, 1)->startOfDay();
162 }
163 /**
164 * Resets the date to end of the decade and time to 23:59:59.999999
165 *
166 * @example
167 * ```
168 * echo Carbon::parse('2018-07-25 12:45:16')->endOfDecade();
169 * ```
170 *
171 * @return static
172 */
173 public function endOfDecade()
174 {
175 $year = $this->year - $this->year % static::YEARS_PER_DECADE + static::YEARS_PER_DECADE - 1;
176 return $this->setDate($year, 12, 31)->endOfDay();
177 }
178 /**
179 * Resets the date to the first day of the century and the time to 00:00:00
180 *
181 * @example
182 * ```
183 * echo Carbon::parse('2018-07-25 12:45:16')->startOfCentury();
184 * ```
185 *
186 * @return static
187 */
188 public function startOfCentury()
189 {
190 $year = $this->year - ($this->year - 1) % static::YEARS_PER_CENTURY;
191 return $this->setDate($year, 1, 1)->startOfDay();
192 }
193 /**
194 * Resets the date to end of the century and time to 23:59:59.999999
195 *
196 * @example
197 * ```
198 * echo Carbon::parse('2018-07-25 12:45:16')->endOfCentury();
199 * ```
200 *
201 * @return static
202 */
203 public function endOfCentury()
204 {
205 $year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_CENTURY + static::YEARS_PER_CENTURY;
206 return $this->setDate($year, 12, 31)->endOfDay();
207 }
208 /**
209 * Resets the date to the first day of the millennium and the time to 00:00:00
210 *
211 * @example
212 * ```
213 * echo Carbon::parse('2018-07-25 12:45:16')->startOfMillennium();
214 * ```
215 *
216 * @return static
217 */
218 public function startOfMillennium()
219 {
220 $year = $this->year - ($this->year - 1) % static::YEARS_PER_MILLENNIUM;
221 return $this->setDate($year, 1, 1)->startOfDay();
222 }
223 /**
224 * Resets the date to end of the millennium and time to 23:59:59.999999
225 *
226 * @example
227 * ```
228 * echo Carbon::parse('2018-07-25 12:45:16')->endOfMillennium();
229 * ```
230 *
231 * @return static
232 */
233 public function endOfMillennium()
234 {
235 $year = $this->year - 1 - ($this->year - 1) % static::YEARS_PER_MILLENNIUM + static::YEARS_PER_MILLENNIUM;
236 return $this->setDate($year, 12, 31)->endOfDay();
237 }
238 /**
239 * Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
240 *
241 * @example
242 * ```
243 * echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek() . "\n";
244 * echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->startOfWeek() . "\n";
245 * echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek(Carbon::SUNDAY) . "\n";
246 * ```
247 *
248 * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week
249 *
250 * @return static
251 */
252 public function startOfWeek($weekStartsAt = null)
253 {
254 return $this->subDays((7 + $this->dayOfWeek - ($weekStartsAt ?? $this->firstWeekDay)) % 7)->startOfDay();
255 }
256 /**
257 * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59.999999
258 *
259 * @example
260 * ```
261 * echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek() . "\n";
262 * echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->endOfWeek() . "\n";
263 * echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek(Carbon::SATURDAY) . "\n";
264 * ```
265 *
266 * @param int $weekEndsAt optional start allow you to specify the day of week to use to end the week
267 *
268 * @return static
269 */
270 public function endOfWeek($weekEndsAt = null)
271 {
272 return $this->addDays((7 - $this->dayOfWeek + ($weekEndsAt ?? $this->lastWeekDay)) % 7)->endOfDay();
273 }
274 /**
275 * Modify to start of current hour, minutes and seconds become 0
276 *
277 * @example
278 * ```
279 * echo Carbon::parse('2018-07-25 12:45:16')->startOfHour();
280 * ```
281 *
282 * @return static
283 */
284 public function startOfHour()
285 {
286 return $this->setTime($this->hour, 0, 0, 0);
287 }
288 /**
289 * Modify to end of current hour, minutes and seconds become 59
290 *
291 * @example
292 * ```
293 * echo Carbon::parse('2018-07-25 12:45:16')->endOfHour();
294 * ```
295 *
296 * @return static
297 */
298 public function endOfHour()
299 {
300 return $this->setTime($this->hour, static::MINUTES_PER_HOUR - 1, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
301 }
302 /**
303 * Modify to start of current minute, seconds become 0
304 *
305 * @example
306 * ```
307 * echo Carbon::parse('2018-07-25 12:45:16')->startOfMinute();
308 * ```
309 *
310 * @return static
311 */
312 public function startOfMinute()
313 {
314 return $this->setTime($this->hour, $this->minute, 0, 0);
315 }
316 /**
317 * Modify to end of current minute, seconds become 59
318 *
319 * @example
320 * ```
321 * echo Carbon::parse('2018-07-25 12:45:16')->endOfMinute();
322 * ```
323 *
324 * @return static
325 */
326 public function endOfMinute()
327 {
328 return $this->setTime($this->hour, $this->minute, static::SECONDS_PER_MINUTE - 1, static::MICROSECONDS_PER_SECOND - 1);
329 }
330 /**
331 * Modify to start of current second, microseconds become 0
332 *
333 * @example
334 * ```
335 * echo Carbon::parse('2018-07-25 12:45:16.334455')
336 * ->startOfSecond()
337 * ->format('H:i:s.u');
338 * ```
339 *
340 * @return static
341 */
342 public function startOfSecond()
343 {
344 return $this->setTime($this->hour, $this->minute, $this->second, 0);
345 }
346 /**
347 * Modify to end of current second, microseconds become 999999
348 *
349 * @example
350 * ```
351 * echo Carbon::parse('2018-07-25 12:45:16.334455')
352 * ->endOfSecond()
353 * ->format('H:i:s.u');
354 * ```
355 *
356 * @return static
357 */
358 public function endOfSecond()
359 {
360 return $this->setTime($this->hour, $this->minute, $this->second, static::MICROSECONDS_PER_SECOND - 1);
361 }
362 /**
363 * Modify to start of current given unit.
364 *
365 * @example
366 * ```
367 * echo Carbon::parse('2018-07-25 12:45:16.334455')
368 * ->startOf('month')
369 * ->endOf('week', Carbon::FRIDAY);
370 * ```
371 *
372 * @param string $unit
373 * @param array<int, mixed> $params
374 *
375 * @return static
376 */
377 public function startOf($unit, ...$params)
378 {
379 $ucfUnit = \ucfirst(static::singularUnit($unit));
380 $method = "startOf{$ucfUnit}";
381 if (!\method_exists($this, $method)) {
382 throw new UnknownUnitException($unit);
383 }
384 return $this->{$method}(...$params);
385 }
386 /**
387 * Modify to end of current given unit.
388 *
389 * @example
390 * ```
391 * echo Carbon::parse('2018-07-25 12:45:16.334455')
392 * ->startOf('month')
393 * ->endOf('week', Carbon::FRIDAY);
394 * ```
395 *
396 * @param string $unit
397 * @param array<int, mixed> $params
398 *
399 * @return static
400 */
401 public function endOf($unit, ...$params)
402 {
403 $ucfUnit = \ucfirst(static::singularUnit($unit));
404 $method = "endOf{$ucfUnit}";
405 if (!\method_exists($this, $method)) {
406 throw new UnknownUnitException($unit);
407 }
408 return $this->{$method}(...$params);
409 }
410 }
411