DateTime.php 35 KB

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