PhpSpreadsheet/tests/data/Calculation/DateTime/WEEKNUM.php
oleibman cb18163a1d
Changes to WEEKNUM and YEARFRAC (#1316)
* Changes to WEEKNUM and YEARFRAC

The optional second parameter for WEEKNUM can take any of 10 values
(1, 2, 11-17, and 21), but currently only 1 and 2 are supported.
This change adds support for the other 8 possibilities.

YEARFRAC in Excel does not require that end date be before start date,
but PhpSpreadsheet was returning an error in that situation.

YEARFRAC third parameter (method) of 1 was not correctly implemented.
I was able to find a description of the algorithm, and documented
that location in the code, and implemented according to that spec.
PHPExcel had a (failing) test to assert the result of
YEARFRAC("1960-12-19", "2008-06-28", 1). This test had been dropped
from PhpSpreadsheet, and is now restored; several new tests have
been added, and verified against Excel.

* Add YEARFRAC Tests

Scrutinizer reported a very mysterious failure with no details.
project.metric_change("scrutinizer.test_coverage", < 0),
without even a link to explain what it is reporting.
It is possible that it was a complaint about code coverage.
If so, I have added some tests which will, I hope, eliminate the problem.

* Make Array Constant

Responding to review from Mark Baker.

* Merge with PR 1362 Bugfix 1161

Travis CI reported problem with Calculation.php (which is not part
  of this change).
That was changed in master a few days ago
(delete some unused code).
Perhaps the lack of that change is the problem here.
Merging it manually.
2020-02-19 20:22:31 +01:00

177 lines
2.2 KiB
PHP

<?php
return [
[
52,
'21-Dec-2000', 1,
],
[
1,
'2000-01-01', 1,
],
[
2,
'2000-01-02', 1,
],
[
1,
'2000-01-01', 2,
],
[
2,
'2000-01-03', 2,
],
[
1,
'1995-01-01', 1,
],
[
1,
'1995-01-07', 1,
],
[
2,
'1995-01-08', 1,
],
[
1,
'1995-01-01', 2,
],
[
2,
'1995-01-02', 2,
],
[
28,
'3/7/1977',
],
[
'#VALUE!',
'3/7/1977', 'A',
],
[
'#NUM!',
'3/7/1977', 0,
],
[
'#NUM!',
'3/7/1977', -1,
],
[
'#VALUE!',
'Invalid', 1,
],
[
'#NUM!',
-1,
],
[
53,
'2019-12-29', 1,
],
[
52,
'2019-12-29', 2,
],
[
'#NUM!',
'2019-12-29', 3,
],
[
'#NUM!',
'2019-12-29', 10,
],
[
52,
'2019-12-29', 11,
],
[
52,
'2019-12-29', 12,
],
[
53,
'2019-12-29', 13,
],
[
53,
'2019-12-29', 14,
],
[
53,
'2019-12-29', 15,
],
[
53,
'2019-12-29', 16,
],
[
53,
'2019-12-29', 17,
],
[
'#NUM!',
'2019-12-29', 18,
],
[
'#NUM!',
'2019-12-29', 20,
],
[
'#NUM!',
'2019-12-29', 22,
],
[
52,
'2019-12-29', 21,
],
[
53,
'2020-12-29', 21,
],
[
52,
'2021-12-29', 21,
],
[
52,
'2022-12-29', 21,
],
[
1,
'2020-01-01', 21,
],
[
53,
'2021-01-01', 21,
],
[
52,
'2022-01-01', 21,
],
[
52,
'2023-01-01', 21,
],
[
2,
'2020-01-08', 21,
],
[
1,
'2021-01-08', 21,
],
[
1,
'2022-01-08', 21,
],
[
1,
'2023-01-08', 21,
],
[
1,
'2025-12-29', 21,
],
];