PluginProbe
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin / 6.5.1.7
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin v6.5.1.7
6.5.1.7 6.5.1.6 6.5.1.5 6.5.1.4 6.5.1.3 6.5.1.2 6.5.1.1 6.5.0.9 6.5.0.8 6.5.0.7 6.5.0.6 trunk 3.4.2.40 3.4.2.41 3.4.2.42 3.4.2.43 3.4.2.44 3.4.2.45 3.4.2.46 3.4.2.47 3.4.2.48 3.4.2.49 3.4.2.50 6.3.2 6.3.3.1 All 47 releases
wpdatatables / lib / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Calculation / DateTime.php

DateTime.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/DateTime.php

891 lines 35.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Calculation;
4
5 use DateTimeInterface;
6
7 /**
8 * @deprecated 1.18.0
9 */
10 class DateTime
11 {
12 /**
13 * Identify if a year is a leap year or not.
14 *
15 * @deprecated 1.18.0
16 * Use the isLeapYear method in the DateTimeExcel\Helpers class instead
17 * @see DateTimeExcel\Helpers::isLeapYear()
18 *
19 * @param int|string $year The year to test
20 *
21 * @return bool TRUE if the year is a leap year, otherwise FALSE
22 */
23 public static function isLeapYear($year)
24 {
25 return DateTimeExcel\Helpers::isLeapYear($year);
26 }
27
28 /**
29 * getDateValue.
30 *
31 * @deprecated 1.18.0
32 * Use the getDateValue method in the DateTimeExcel\Helpers class instead
33 * @see DateTimeExcel\Helpers::getDateValue()
34 *
35 * @param mixed $dateValue
36 *
37 * @return mixed Excel date/time serial value, or string if error
38 */
39 public static function getDateValue($dateValue)
40 {
41 try {
42 return DateTimeExcel\Helpers::getDateValue($dateValue);
43 } catch (Exception $e) {
44 return $e->getMessage();
45 }
46 }
47
48 /**
49 * DATETIMENOW.
50 *
51 * Returns the current date and time.
52 * The NOW function is useful when you need to display the current date and time on a worksheet or
53 * calculate a value based on the current date and time, and have that value updated each time you
54 * open the worksheet.
55 *
56 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
57 * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
58 *
59 * Excel Function:
60 * NOW()
61 *
62 * @deprecated 1.18.0
63 * Use the now method in the DateTimeExcel\Current class instead
64 * @see DateTimeExcel\Current::now()
65 *
66 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
67 * depending on the value of the ReturnDateType flag
68 */
69 public static function DATETIMENOW()
70 {
71 return DateTimeExcel\Current::now();
72 }
73
74 /**
75 * DATENOW.
76 *
77 * Returns the current date.
78 * The NOW function is useful when you need to display the current date and time on a worksheet or
79 * calculate a value based on the current date and time, and have that value updated each time you
80 * open the worksheet.
81 *
82 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
83 * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
84 *
85 * Excel Function:
86 * TODAY()
87 *
88 * @deprecated 1.18.0
89 * Use the today method in the DateTimeExcel\Current class instead
90 * @see DateTimeExcel\Current::today()
91 *
92 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
93 * depending on the value of the ReturnDateType flag
94 */
95 public static function DATENOW()
96 {
97 return DateTimeExcel\Current::today();
98 }
99
100 /**
101 * DATE.
102 *
103 * The DATE function returns a value that represents a particular date.
104 *
105 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
106 * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
107 *
108 *
109 * Excel Function:
110 * DATE(year,month,day)
111 *
112 * @deprecated 1.18.0
113 * Use the fromYMD method in the DateTimeExcel\Date class instead
114 * @see DateTimeExcel\Date::fromYMD()
115 *
116 * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function.
117 * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted,
118 * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language.
119 *
120 * @param int $year The value of the year argument can include one to four digits.
121 * Excel interprets the year argument according to the configured
122 * date system: 1900 or 1904.
123 * If year is between 0 (zero) and 1899 (inclusive), Excel adds that
124 * value to 1900 to calculate the year. For example, DATE(108,1,2)
125 * returns January 2, 2008 (1900+108).
126 * If year is between 1900 and 9999 (inclusive), Excel uses that
127 * value as the year. For example, DATE(2008,1,2) returns January 2,
128 * 2008.
129 * If year is less than 0 or is 10000 or greater, Excel returns the
130 * #NUM! error value.
131 * @param int $month A positive or negative integer representing the month of the year
132 * from 1 to 12 (January to December).
133 * If month is greater than 12, month adds that number of months to
134 * the first month in the year specified. For example, DATE(2008,14,2)
135 * returns the serial number representing February 2, 2009.
136 * If month is less than 1, month subtracts the magnitude of that
137 * number of months, plus 1, from the first month in the year
138 * specified. For example, DATE(2008,-3,2) returns the serial number
139 * representing September 2, 2007.
140 * @param int $day A positive or negative integer representing the day of the month
141 * from 1 to 31.
142 * If day is greater than the number of days in the month specified,
143 * day adds that number of days to the first day in the month. For
144 * example, DATE(2008,1,35) returns the serial number representing
145 * February 4, 2008.
146 * If day is less than 1, day subtracts the magnitude that number of
147 * days, plus one, from the first day of the month specified. For
148 * example, DATE(2008,1,-15) returns the serial number representing
149 * December 16, 2007.
150 *
151 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
152 * depending on the value of the ReturnDateType flag
153 */
154 public static function DATE($year = 0, $month = 1, $day = 1)
155 {
156 return DateTimeExcel\Date::fromYMD($year, $month, $day);
157 }
158
159 /**
160 * TIME.
161 *
162 * The TIME function returns a value that represents a particular time.
163 *
164 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
165 * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
166 *
167 * Excel Function:
168 * TIME(hour,minute,second)
169 *
170 * @deprecated 1.18.0
171 * Use the fromHMS method in the DateTimeExcel\Time class instead
172 * @see DateTimeExcel\Time::fromHMS()
173 *
174 * @param int $hour A number from 0 (zero) to 32767 representing the hour.
175 * Any value greater than 23 will be divided by 24 and the remainder
176 * will be treated as the hour value. For example, TIME(27,0,0) =
177 * TIME(3,0,0) = .125 or 3:00 AM.
178 * @param int $minute A number from 0 to 32767 representing the minute.
179 * Any value greater than 59 will be converted to hours and minutes.
180 * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
181 * @param int $second A number from 0 to 32767 representing the second.
182 * Any value greater than 59 will be converted to hours, minutes,
183 * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148
184 * or 12:33:20 AM
185 *
186 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
187 * depending on the value of the ReturnDateType flag
188 */
189 public static function TIME($hour = 0, $minute = 0, $second = 0)
190 {
191 return DateTimeExcel\Time::fromHMS($hour, $minute, $second);
192 }
193
194 /**
195 * DATEVALUE.
196 *
197 * Returns a value that represents a particular date.
198 * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp
199 * value.
200 *
201 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date
202 * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
203 *
204 * Excel Function:
205 * DATEVALUE(dateValue)
206 *
207 * @deprecated 1.18.0
208 * Use the fromString method in the DateTimeExcel\DateValue class instead
209 * @see DateTimeExcel\DateValue::fromString()
210 *
211 * @param string $dateValue Text that represents a date in a Microsoft Excel date format.
212 * For example, "1/30/2008" or "30-Jan-2008" are text strings within
213 * quotation marks that represent dates. Using the default date
214 * system in Excel for Windows, date_text must represent a date from
215 * January 1, 1900, to December 31, 9999. Using the default date
216 * system in Excel for the Macintosh, date_text must represent a date
217 * from January 1, 1904, to December 31, 9999. DATEVALUE returns the
218 * #VALUE! error value if date_text is out of this range.
219 *
220 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
221 * depending on the value of the ReturnDateType flag
222 */
223 public static function DATEVALUE($dateValue)
224 {
225 return DateTimeExcel\DateValue::fromString($dateValue);
226 }
227
228 /**
229 * TIMEVALUE.
230 *
231 * Returns a value that represents a particular time.
232 * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp
233 * value.
234 *
235 * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
236 * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
237 *
238 * Excel Function:
239 * TIMEVALUE(timeValue)
240 *
241 * @deprecated 1.18.0
242 * Use the fromString method in the DateTimeExcel\TimeValue class instead
243 * @see DateTimeExcel\TimeValue::fromString()
244 *
245 * @param string $timeValue A text string that represents a time in any one of the Microsoft
246 * Excel time formats; for example, "6:45 PM" and "18:45" text strings
247 * within quotation marks that represent time.
248 * Date information in time_text is ignored.
249 *
250 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
251 * depending on the value of the ReturnDateType flag
252 */
253 public static function TIMEVALUE($timeValue)
254 {
255 return DateTimeExcel\TimeValue::fromString($timeValue);
256 }
257
258 /**
259 * DATEDIF.
260 *
261 * Excel Function:
262 * DATEDIF(startdate, enddate, unit)
263 *
264 * @deprecated 1.18.0
265 * Use the interval method in the DateTimeExcel\Difference class instead
266 * @see DateTimeExcel\Difference::interval()
267 *
268 * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object
269 * or a standard date string
270 * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object
271 * or a standard date string
272 * @param array|string $unit
273 *
274 * @return array|int|string Interval between the dates
275 */
276 public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
277 {
278 return DateTimeExcel\Difference::interval($startDate, $endDate, $unit);
279 }
280
281 /**
282 * DAYS.
283 *
284 * Returns the number of days between two dates
285 *
286 * Excel Function:
287 * DAYS(endDate, startDate)
288 *
289 * @deprecated 1.18.0
290 * Use the between method in the DateTimeExcel\Days class instead
291 * @see DateTimeExcel\Days::between()
292 *
293 * @param array|DateTimeInterface|float|int|string $endDate Excel date serial value (float),
294 * PHP date timestamp (integer), PHP DateTime object, or a standard date string
295 * @param array|DateTimeInterface|float|int|string $startDate Excel date serial value (float),
296 * PHP date timestamp (integer), PHP DateTime object, or a standard date string
297 *
298 * @return array|int|string Number of days between start date and end date or an error
299 */
300 public static function DAYS($endDate = 0, $startDate = 0)
301 {
302 return DateTimeExcel\Days::between($endDate, $startDate);
303 }
304
305 /**
306 * DAYS360.
307 *
308 * Returns the number of days between two dates based on a 360-day year (twelve 30-day months),
309 * which is used in some accounting calculations. Use this function to help compute payments if
310 * your accounting system is based on twelve 30-day months.
311 *
312 * Excel Function:
313 * DAYS360(startDate,endDate[,method])
314 *
315 * @deprecated 1.18.0
316 * Use the between method in the DateTimeExcel\Days360 class instead
317 * @see DateTimeExcel\Days360::between()
318 *
319 * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
320 * PHP DateTime object, or a standard date string
321 * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
322 * PHP DateTime object, or a standard date string
323 * @param array|bool $method US or European Method
324 * FALSE or omitted: U.S. (NASD) method. If the starting date is
325 * the last day of a month, it becomes equal to the 30th of the
326 * same month. If the ending date is the last day of a month and
327 * the starting date is earlier than the 30th of a month, the
328 * ending date becomes equal to the 1st of the next month;
329 * otherwise the ending date becomes equal to the 30th of the
330 * same month.
331 * TRUE: European method. Starting dates and ending dates that
332 * occur on the 31st of a month become equal to the 30th of the
333 * same month.
334 *
335 * @return array|int|string Number of days between start date and end date
336 */
337 public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
338 {
339 return DateTimeExcel\Days360::between($startDate, $endDate, $method);
340 }
341
342 /**
343 * YEARFRAC.
344 *
345 * Calculates the fraction of the year represented by the number of whole days between two dates
346 * (the start_date and the end_date).
347 * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or
348 * obligations to assign to a specific term.
349 *
350 * Excel Function:
351 * YEARFRAC(startDate,endDate[,method])
352 *
353 * @deprecated 1.18.0
354 * Use the fraction method in the DateTimeExcel\YearFrac class instead
355 * @see DateTimeExcel\YearFrac::fraction()
356 *
357 * See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html
358 * for description of algorithm used in Excel
359 *
360 * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
361 * PHP DateTime object, or a standard date string
362 * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
363 * PHP DateTime object, or a standard date string
364 * @param array|int $method Method used for the calculation
365 * 0 or omitted US (NASD) 30/360
366 * 1 Actual/actual
367 * 2 Actual/360
368 * 3 Actual/365
369 * 4 European 30/360
370 *
371 * @return array|float|string fraction of the year, or a string containing an error
372 */
373 public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0)
374 {
375 return DateTimeExcel\YearFrac::fraction($startDate, $endDate, $method);
376 }
377
378 /**
379 * NETWORKDAYS.
380 *
381 * Returns the number of whole working days between start_date and end_date. Working days
382 * exclude weekends and any dates identified in holidays.
383 * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days
384 * worked during a specific term.
385 *
386 * Excel Function:
387 * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]])
388 *
389 * @deprecated 1.18.0
390 * Use the count method in the DateTimeExcel\NetworkDays class instead
391 * @see DateTimeExcel\NetworkDays::count()
392 *
393 * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
394 * PHP DateTime object, or a standard date string
395 * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer),
396 * PHP DateTime object, or a standard date string
397 * @param mixed $dateArgs
398 *
399 * @return array|int|string Interval between the dates
400 */
401 public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs)
402 {
403 return DateTimeExcel\NetworkDays::count($startDate, $endDate, ...$dateArgs);
404 }
405
406 /**
407 * WORKDAY.
408 *
409 * Returns the date that is the indicated number of working days before or after a date (the
410 * starting date). Working days exclude weekends and any dates identified as holidays.
411 * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected
412 * delivery times, or the number of days of work performed.
413 *
414 * Excel Function:
415 * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]])
416 *
417 * @deprecated 1.18.0
418 * Use the date method in the DateTimeExcel\WorkDay class instead
419 * @see DateTimeExcel\WorkDay::date()
420 *
421 * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
422 * PHP DateTime object, or a standard date string
423 * @param int $endDays The number of nonweekend and nonholiday days before or after
424 * startDate. A positive value for days yields a future date; a
425 * negative value yields a past date.
426 * @param mixed $dateArgs
427 *
428 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
429 * depending on the value of the ReturnDateType flag
430 */
431 public static function WORKDAY($startDate, $endDays, ...$dateArgs)
432 {
433 return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs);
434 }
435
436 /**
437 * DAYOFMONTH.
438 *
439 * Returns the day of the month, for a specified date. The day is given as an integer
440 * ranging from 1 to 31.
441 *
442 * Excel Function:
443 * DAY(dateValue)
444 *
445 * @deprecated 1.18.0
446 * Use the day method in the DateTimeExcel\DateParts class instead
447 * @see DateTimeExcel\DateParts::day()
448 *
449 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
450 * PHP DateTime object, or a standard date string
451 *
452 * @return array|int|string Day of the month
453 */
454 public static function DAYOFMONTH($dateValue = 1)
455 {
456 return DateTimeExcel\DateParts::day($dateValue);
457 }
458
459 /**
460 * WEEKDAY.
461 *
462 * Returns the day of the week for a specified date. The day is given as an integer
463 * ranging from 0 to 7 (dependent on the requested style).
464 *
465 * Excel Function:
466 * WEEKDAY(dateValue[,style])
467 *
468 * @deprecated 1.18.0
469 * Use the day method in the DateTimeExcel\Week class instead
470 * @see DateTimeExcel\Week::day()
471 *
472 * @param float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer),
473 * PHP DateTime object, or a standard date string
474 * @param int $style A number that determines the type of return value
475 * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday).
476 * 2 Numbers 1 (Monday) through 7 (Sunday).
477 * 3 Numbers 0 (Monday) through 6 (Sunday).
478 *
479 * @return array|int|string Day of the week value
480 */
481 public static function WEEKDAY($dateValue = 1, $style = 1)
482 {
483 return DateTimeExcel\Week::day($dateValue, $style);
484 }
485
486 /**
487 * STARTWEEK_SUNDAY.
488 *
489 * @deprecated 1.18.0
490 * Use DateTimeExcel\Constants::STARTWEEK_SUNDAY
491 * @see DateTimeExcel\Constants::STARTWEEK_SUNDAY
492 */
493 const STARTWEEK_SUNDAY = 1;
494
495 /**
496 * STARTWEEK_MONDAY.
497 *
498 * @deprecated 1.18.0
499 * Use DateTimeExcel\Constants::STARTWEEK_MONDAY
500 * @see DateTimeExcel\Constants::STARTWEEK_MONDAY
501 */
502 const STARTWEEK_MONDAY = 2;
503
504 /**
505 * STARTWEEK_MONDAY_ALT.
506 *
507 * @deprecated 1.18.0
508 * Use DateTimeExcel\Constants::STARTWEEK_MONDAY_ALT
509 * @see DateTimeExcel\Constants::STARTWEEK_MONDAY_ALT
510 */
511 const STARTWEEK_MONDAY_ALT = 11;
512
513 /**
514 * STARTWEEK_TUESDAY.
515 *
516 * @deprecated 1.18.0
517 * Use DateTimeExcel\Constants::STARTWEEK_TUESDAY
518 * @see DateTimeExcel\Constants::STARTWEEK_TUESDAY
519 */
520 const STARTWEEK_TUESDAY = 12;
521
522 /**
523 * STARTWEEK_WEDNESDAY.
524 *
525 * @deprecated 1.18.0
526 * Use DateTimeExcel\Constants::STARTWEEK_WEDNESDAY
527 * @see DateTimeExcel\Constants::STARTWEEK_WEDNESDAY
528 */
529 const STARTWEEK_WEDNESDAY = 13;
530
531 /**
532 * STARTWEEK_THURSDAY.
533 *
534 * @deprecated 1.18.0
535 * Use DateTimeExcel\Constants::STARTWEEK_THURSDAY
536 * @see DateTimeExcel\Constants::STARTWEEK_THURSDAY
537 */
538 const STARTWEEK_THURSDAY = 14;
539
540 /**
541 * STARTWEEK_FRIDAY.
542 *
543 * @deprecated 1.18.0
544 * Use DateTimeExcel\Constants::STARTWEEK_FRIDAY
545 * @see DateTimeExcel\Constants::STARTWEEK_FRIDAY
546 */
547 const STARTWEEK_FRIDAY = 15;
548
549 /**
550 * STARTWEEK_SATURDAY.
551 *
552 * @deprecated 1.18.0
553 * Use DateTimeExcel\Constants::STARTWEEK_SATURDAY
554 * @see DateTimeExcel\Constants::STARTWEEK_SATURDAY
555 */
556 const STARTWEEK_SATURDAY = 16;
557
558 /**
559 * STARTWEEK_SUNDAY_ALT.
560 *
561 * @deprecated 1.18.0
562 * Use DateTimeExcel\Constants::STARTWEEK_SUNDAY_ALT
563 * @see DateTimeExcel\Constants::STARTWEEK_SUNDAY_ALT
564 */
565 const STARTWEEK_SUNDAY_ALT = 17;
566
567 /**
568 * DOW_SUNDAY.
569 *
570 * @deprecated 1.18.0
571 * Use DateTimeExcel\Constants::DOW_SUNDAY
572 * @see DateTimeExcel\Constants::DOW_SUNDAY
573 */
574 const DOW_SUNDAY = 1;
575
576 /**
577 * DOW_MONDAY.
578 *
579 * @deprecated 1.18.0
580 * Use DateTimeExcel\Constants::DOW_MONDAY
581 * @see DateTimeExcel\Constants::DOW_MONDAY
582 */
583 const DOW_MONDAY = 2;
584
585 /**
586 * DOW_TUESDAY.
587 *
588 * @deprecated 1.18.0
589 * Use DateTimeExcel\Constants::DOW_TUESDAY
590 * @see DateTimeExcel\Constants::DOW_TUESDAY
591 */
592 const DOW_TUESDAY = 3;
593
594 /**
595 * DOW_WEDNESDAY.
596 *
597 * @deprecated 1.18.0
598 * Use DateTimeExcel\Constants::DOW_WEDNESDAY
599 * @see DateTimeExcel\Constants::DOW_WEDNESDAY
600 */
601 const DOW_WEDNESDAY = 4;
602
603 /**
604 * DOW_THURSDAY.
605 *
606 * @deprecated 1.18.0
607 * Use DateTimeExcel\Constants::DOW_THURSDAY
608 * @see DateTimeExcel\Constants::DOW_THURSDAY
609 */
610 const DOW_THURSDAY = 5;
611
612 /**
613 * DOW_FRIDAY.
614 *
615 * @deprecated 1.18.0
616 * Use DateTimeExcel\Constants::DOW_FRIDAY
617 * @see DateTimeExcel\Constants::DOW_FRIDAY
618 */
619 const DOW_FRIDAY = 6;
620
621 /**
622 * DOW_SATURDAY.
623 *
624 * @deprecated 1.18.0
625 * Use DateTimeExcel\Constants::DOW_SATURDAY
626 * @see DateTimeExcel\Constants::DOW_SATURDAY
627 */
628 const DOW_SATURDAY = 7;
629
630 /**
631 * STARTWEEK_MONDAY_ISO.
632 *
633 * @deprecated 1.18.0
634 * Use DateTimeExcel\Constants::STARTWEEK_MONDAY_ISO
635 * @see DateTimeExcel\Constants::STARTWEEK_MONDAY_ISO
636 */
637 const STARTWEEK_MONDAY_ISO = 21;
638
639 /**
640 * METHODARR.
641 *
642 * @deprecated 1.18.0
643 * Use DateTimeExcel\Constants::METHODARR
644 * @see DateTimeExcel\Constants::METHODARR
645 */
646 const METHODARR = [
647 self::STARTWEEK_SUNDAY => self::DOW_SUNDAY,
648 self::DOW_MONDAY,
649 self::STARTWEEK_MONDAY_ALT => self::DOW_MONDAY,
650 self::DOW_TUESDAY,
651 self::DOW_WEDNESDAY,
652 self::DOW_THURSDAY,
653 self::DOW_FRIDAY,
654 self::DOW_SATURDAY,
655 self::DOW_SUNDAY,
656 self::STARTWEEK_MONDAY_ISO => self::STARTWEEK_MONDAY_ISO,
657 ];
658
659 /**
660 * WEEKNUM.
661 *
662 * Returns the week of the year for a specified date.
663 * The WEEKNUM function considers the week containing January 1 to be the first week of the year.
664 * However, there is a European standard that defines the first week as the one with the majority
665 * of days (four or more) falling in the new year. This means that for years in which there are
666 * three days or less in the first week of January, the WEEKNUM function returns week numbers
667 * that are incorrect according to the European standard.
668 *
669 * Excel Function:
670 * WEEKNUM(dateValue[,style])
671 *
672 * @deprecated 1.18.0
673 * Use the number method in the DateTimeExcel\Week class instead
674 * @see DateTimeExcel\Week::number()
675 *
676 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
677 * PHP DateTime object, or a standard date string
678 * @param int $method Week begins on Sunday or Monday
679 * 1 or omitted Week begins on Sunday.
680 * 2 Week begins on Monday.
681 * 11 Week begins on Monday.
682 * 12 Week begins on Tuesday.
683 * 13 Week begins on Wednesday.
684 * 14 Week begins on Thursday.
685 * 15 Week begins on Friday.
686 * 16 Week begins on Saturday.
687 * 17 Week begins on Sunday.
688 * 21 ISO (Jan. 4 is week 1, begins on Monday).
689 *
690 * @return array|int|string Week Number
691 */
692 public static function WEEKNUM($dateValue = 1, $method = /** @scrutinizer ignore-deprecated */ self::STARTWEEK_SUNDAY)
693 {
694 return DateTimeExcel\Week::number($dateValue, $method);
695 }
696
697 /**
698 * ISOWEEKNUM.
699 *
700 * Returns the ISO 8601 week number of the year for a specified date.
701 *
702 * Excel Function:
703 * ISOWEEKNUM(dateValue)
704 *
705 * @deprecated 1.18.0
706 * Use the isoWeekNumber method in the DateTimeExcel\Week class instead
707 * @see DateTimeExcel\Week::isoWeekNumber()
708 *
709 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
710 * PHP DateTime object, or a standard date string
711 *
712 * @return array|int|string Week Number
713 */
714 public static function ISOWEEKNUM($dateValue = 1)
715 {
716 return DateTimeExcel\Week::isoWeekNumber($dateValue);
717 }
718
719 /**
720 * MONTHOFYEAR.
721 *
722 * Returns the month of a date represented by a serial number.
723 * The month is given as an integer, ranging from 1 (January) to 12 (December).
724 *
725 * Excel Function:
726 * MONTH(dateValue)
727 *
728 * @deprecated 1.18.0
729 * Use the month method in the DateTimeExcel\DateParts class instead
730 * @see DateTimeExcel\DateParts::month()
731 *
732 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
733 * PHP DateTime object, or a standard date string
734 *
735 * @return array|int|string Month of the year
736 */
737 public static function MONTHOFYEAR($dateValue = 1)
738 {
739 return DateTimeExcel\DateParts::month($dateValue);
740 }
741
742 /**
743 * YEAR.
744 *
745 * Returns the year corresponding to a date.
746 * The year is returned as an integer in the range 1900-9999.
747 *
748 * Excel Function:
749 * YEAR(dateValue)
750 *
751 * @deprecated 1.18.0
752 * Use the ear method in the DateTimeExcel\DateParts class instead
753 * @see DateTimeExcel\DateParts::year()
754 *
755 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
756 * PHP DateTime object, or a standard date string
757 *
758 * @return array|int|string Year
759 */
760 public static function YEAR($dateValue = 1)
761 {
762 return DateTimeExcel\DateParts::year($dateValue);
763 }
764
765 /**
766 * HOUROFDAY.
767 *
768 * Returns the hour of a time value.
769 * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
770 *
771 * Excel Function:
772 * HOUR(timeValue)
773 *
774 * @deprecated 1.18.0
775 * Use the hour method in the DateTimeExcel\TimeParts class instead
776 * @see DateTimeExcel\TimeParts::hour()
777 *
778 * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
779 * PHP DateTime object, or a standard time string
780 *
781 * @return array|int|string Hour
782 */
783 public static function HOUROFDAY($timeValue = 0)
784 {
785 return DateTimeExcel\TimeParts::hour($timeValue);
786 }
787
788 /**
789 * MINUTE.
790 *
791 * Returns the minutes of a time value.
792 * The minute is given as an integer, ranging from 0 to 59.
793 *
794 * Excel Function:
795 * MINUTE(timeValue)
796 *
797 * @deprecated 1.18.0
798 * Use the minute method in the DateTimeExcel\TimeParts class instead
799 * @see DateTimeExcel\TimeParts::minute()
800 *
801 * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
802 * PHP DateTime object, or a standard time string
803 *
804 * @return array|int|string Minute
805 */
806 public static function MINUTE($timeValue = 0)
807 {
808 return DateTimeExcel\TimeParts::minute($timeValue);
809 }
810
811 /**
812 * SECOND.
813 *
814 * Returns the seconds of a time value.
815 * The second is given as an integer in the range 0 (zero) to 59.
816 *
817 * Excel Function:
818 * SECOND(timeValue)
819 *
820 * @deprecated 1.18.0
821 * Use the second method in the DateTimeExcel\TimeParts class instead
822 * @see DateTimeExcel\TimeParts::second()
823 *
824 * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer),
825 * PHP DateTime object, or a standard time string
826 *
827 * @return array|int|string Second
828 */
829 public static function SECOND($timeValue = 0)
830 {
831 return DateTimeExcel\TimeParts::second($timeValue);
832 }
833
834 /**
835 * EDATE.
836 *
837 * Returns the serial number that represents the date that is the indicated number of months
838 * before or after a specified date (the start_date).
839 * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
840 * as the date of issue.
841 *
842 * Excel Function:
843 * EDATE(dateValue,adjustmentMonths)
844 *
845 * @deprecated 1.18.0
846 * Use the adjust method in the DateTimeExcel\Edate class instead
847 * @see DateTimeExcel\Month::adjust()
848 *
849 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
850 * PHP DateTime object, or a standard date string
851 * @param int $adjustmentMonths The number of months before or after start_date.
852 * A positive value for months yields a future date;
853 * a negative value yields a past date.
854 *
855 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
856 * depending on the value of the ReturnDateType flag
857 */
858 public static function EDATE($dateValue = 1, $adjustmentMonths = 0)
859 {
860 return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths);
861 }
862
863 /**
864 * EOMONTH.
865 *
866 * Returns the date value for the last day of the month that is the indicated number of months
867 * before or after start_date.
868 * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
869 *
870 * Excel Function:
871 * EOMONTH(dateValue,adjustmentMonths)
872 *
873 * @deprecated 1.18.0
874 * Use the lastDay method in the DateTimeExcel\EoMonth class instead
875 * @see DateTimeExcel\Month::lastDay()
876 *
877 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
878 * PHP DateTime object, or a standard date string
879 * @param int $adjustmentMonths The number of months before or after start_date.
880 * A positive value for months yields a future date;
881 * a negative value yields a past date.
882 *
883 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
884 * depending on the value of the ReturnDateType flag
885 */
886 public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0)
887 {
888 return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths);
889 }
890 }
891