PhpSpreadsheet/tests/data/Calculation/DateTime/YEARFRAC.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

564 lines
8.3 KiB
PHP

<?php
return [
[
0.025,
'2007-1-1',
'2007-1-10',
0,
],
[
0.025,
'2007-1-10',
'2007-1-1',
0,
],
[
0.024657534246580001,
'2007-1-1',
'2007-1-10',
1,
],
[
0.025,
'2007-1-1',
'2007-1-10',
2,
],
[
0.024657534246580001,
'2007-1-1',
'2007-1-10',
3,
],
[
0.025,
'2007-1-1',
'2007-1-10',
4,
],
[
1.0,
'2007-1-1',
'2007-12-31',
0,
],
[
0.99726027397259998,
'2007-1-1',
'2007-12-31',
1,
],
[
1.01111111111111,
'2007-1-1',
'2007-12-31',
2,
],
[
0.99726027397259998,
'2007-1-1',
'2007-12-31',
3,
],
[
0.99722222222222001,
'2007-1-1',
'2007-12-31',
4,
],
[
1.5,
'2007-1-1',
'2008-7-1',
0,
],
[
1.49658002735978,
'2007-1-1',
'2008-7-1',
1,
],
[
1.5194444444444399,
'2007-1-1',
'2008-7-1',
2,
],
[
1.4986301369863,
'2007-1-1',
'2008-7-1',
3,
],
[
1.5,
'2007-1-1',
'2008-7-1',
4,
],
[
0.083333333333329998,
'2007-1-1',
'2007-1-31',
0,
],
[
0.082191780821919996,
'2007-1-1',
'2007-1-31',
1,
],
[
0.083333333333329998,
'2007-1-1',
'2007-1-31',
2,
],
[
0.082191780821919996,
'2007-1-1',
'2007-1-31',
3,
],
[
0.080555555555560002,
'2007-1-1',
'2007-1-31',
4,
],
[
0.083333333333329998,
'2007-1-1',
'2007-2-1',
0,
],
[
0.084931506849319993,
'2007-1-1',
'2007-2-1',
1,
],
[
0.08611111111111,
'2007-1-1',
'2007-2-1',
2,
],
[
0.084931506849319993,
'2007-1-1',
'2007-2-1',
3,
],
[
0.083333333333329998,
'2007-1-1',
'2007-2-1',
4,
],
[
0.15833333333333,
'2007-1-1',
'2007-2-28',
0,
],
[
0.15890410958904,
'2007-1-1',
'2007-2-28',
1,
],
[
0.16111111111111001,
'2007-1-1',
'2007-2-28',
2,
],
[
0.15890410958904,
'2007-1-1',
'2007-2-28',
3,
],
[
0.15833333333333,
'2007-1-1',
'2007-2-28',
4,
],
[
0.0027777777777800001,
'2007-1-31',
'2007-2-1',
0,
],
[
0.0027397260273999999,
'2007-1-31',
'2007-2-1',
1,
],
[
0.0027777777777800001,
'2007-1-31',
'2007-2-1',
2,
],
[
0.0027397260273999999,
'2007-1-31',
'2007-2-1',
3,
],
[
0.0027777777777800001,
'2007-1-31',
'2007-2-1',
4,
],
[
0.08611111111111,
'2007-1-31',
'2007-3-1',
0,
],
[
0.07945205479452,
'2007-1-31',
'2007-3-1',
1,
],
[
0.080555555555560002,
'2007-1-31',
'2007-3-1',
2,
],
[
0.07945205479452,
'2007-1-31',
'2007-3-1',
3,
],
[
0.08611111111111,
'2007-1-31',
'2007-3-1',
4,
],
[
0.16666666666666999,
'2007-1-31',
'2007-3-31',
0,
],
[
0.16164383561644,
'2007-1-31',
'2007-3-31',
1,
],
[
0.16388888888889,
'2007-1-31',
'2007-3-31',
2,
],
[
0.16164383561644,
'2007-1-31',
'2007-3-31',
3,
],
[
0.16666666666666999,
'2007-1-31',
'2007-3-31',
4,
],
[
0.66666666666666996,
'2008-1-1',
'2008-9-1',
0,
],
[
0.66666666666666996,
'2008-1-1',
'2008-9-1',
1,
],
[
0.67777777777778003,
'2008-1-1',
'2008-9-1',
2,
],
[
0.66849315068492998,
'2008-1-1',
'2008-9-1',
3,
],
[
0.66666666666666996,
'2008-1-1',
'2008-9-1',
4,
],
[
1.1666666666666701,
'2007-2-1',
'2008-4-1',
0,
],
[
1.16279069767442,
'2007-2-1',
'2008-4-1',
1,
],
[
1.18055555555556,
'2007-2-1',
'2008-4-1',
2,
],
[
1.16438356164384,
'2007-2-1',
'2008-4-1',
3,
],
[
1.1666666666666701,
'2007-2-1',
'2008-4-1',
4,
],
[
47.524999999999999,
'1960-12-19',
'2008-6-28',
0,
],
[
47.52162252765670,
'1960-12-19',
'2008-6-28',
1,
],
[
48.216666666666697,
'1960-12-19',
'2008-6-28',
2,
],
[
47.556164383561601,
'1960-12-19',
'2008-6-28',
3,
],
[
47.524999999999999,
'1960-12-19',
'2008-6-28',
4,
],
[
25.558333333333302,
'1982-12-7',
'2008-6-28',
0,
],
[
25.5571892111134,
'1982-12-7',
'2008-6-28',
1,
],
[
25.9305555555556,
'1982-12-7',
'2008-6-28',
2,
],
[
25.575342465753401,
'1982-12-7',
'2008-6-28',
3,
],
[
25.558333333333302,
'1982-12-7',
'2008-6-28',
4,
],
[
0.163934426,
'1960-01-01',
'1960-03-01',
1,
],
[
0.161643836,
'1961-01-01',
'1961-03-01',
1,
],
[
0.161643836,
'1963-03-01',
'1963-01-01',
1,
],
[
1.086183311,
'1960-01-01',
'1961-02-01',
1,
],
[
1.084931507,
'1961-01-01',
'1962-02-01',
1,
],
[
1.083447332,
'1963-01-01',
'1964-02-01',
1,
],
[
1.162790698,
'1963-01-01',
'1964-03-01',
1,
],
[
0.841530055,
'2020-02-28',
'2021-01-01',
1,
],
[
0.764383562,
'2020-03-28',
'2021-01-01',
1,
],
[
0.841530055,
'2023-04-28',
'2024-03-01',
1,
],
[
0.838797814,
'2023-04-28',
'2024-02-29',
1,
],
[
0.838356164,
'2023-04-28',
'2024-02-28',
1,
],
[
0.753424658,
'2023-04-28',
'2024-01-28',
1,
],
[
0.753424658,
'2022-04-28',
'2023-01-28',
1,
],
[
1.0,
'2020-01-01',
'2021-01-01',
1,
],
[
0.99726776,
'2020-02-28',
'2021-02-27',
1,
],
[
0.764383562,
'2020-03-28',
'2021-01-01',
1,
],
[
0.841530055,
'2023-04-28',
'2024-03-01',
1,
],
[
0.838797814,
'2023-04-28',
'2024-02-29',
1,
],
[
0.838356164,
'2023-04-28',
'2024-02-28',
1,
],
[
0.753424658,
'2023-04-28',
'2024-01-28',
1,
],
[
0.753424658,
'2022-04-28',
'2023-01-28',
1,
],
[
1.082191781,
'2022-04-28',
'2023-05-28',
1,
],
[
1.002739726,
'2022-04-27',
'2023-04-28',
1,
],
[
0.084699454,
'2024-04-27',
'2024-05-28',
1,
],
[
0.084931507,
'2023-04-27',
'2023-05-28',
1,
],
[
2.085766423,
'2023-04-27',
'2025-05-28',
1,
],
];