Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculation - DATEDIF - fix result for Y & YM units #1466

Merged
merged 1 commit into from
May 25, 2020
Merged

Calculation - DATEDIF - fix result for Y & YM units #1466

merged 1 commit into from
May 25, 2020

Conversation

albanduval
Copy link
Contributor

@albanduval albanduval commented May 11, 2020

This is:

  • a bugfix
  • a new feature

Checklist:

Why this change is needed?

To solve the issue #1465

Attached is a zip file containing :

  • a PHP CLI tool to run a batch of tests that exports the results into CSV files
  • the CSV results for current master branch
  • the CSV results for the code with fix

The results show differences in the results for both Y & YM units, correcting the detected wrong results.

@albanduval albanduval marked this pull request as draft May 11, 2020 08:41
Bugfix for negative results and too small results

2000-02-02 => 2001-02-01
 > DATEDIF with Y unit: 0 year (returned -1 before fix)
 > DATEDIF with YM unit: 11 months (returned -1 before fix)
@albanduval albanduval marked this pull request as ready for review May 11, 2020 09:37
@albanduval albanduval changed the title Calcualtion - DATEDIF - fix result for Y & YM units Calculation - DATEDIF - fix result for Y & YM units May 11, 2020
@MarkBaker
Copy link
Member

Thank you for this submission. The original code was ported from the older PHPExcel library, with it's PHP 5.2 minimal version, so using DateInterval was never an option, and the code wasn't perfect. Now, with PHPSpreadsheet's higher minimum version, it is an option; so thank you for working on this update, and for resolving the issues that were in the original code.

Your work is appreciated.

@MarkBaker MarkBaker merged commit 7ed96e0 into PHPOffice:master May 25, 2020
@albanduval albanduval deleted the issue-1465-fix-datedif branch May 26, 2020 14:50
PowerKiKi added a commit that referenced this pull request May 31, 2020
### Added

- Support writing to streams in all writers [#1292](#1292)
- Support CSV files with data wrapping a lot of lines [#1468](#1468)
- Support protection of worksheet by a specific hash algorithm [#1485](#1485)

### Fixed

- Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](#1448)
- Fix return type in docblock for the Cells::get() [#1398](#1398)
- Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](#1456)
- Save Excel 2010+ functions properly in XLSX [#1461](#1461)
- Several improvements in HTML writer [#1464](#1464)
- Fix incorrect behaviour when saving XLSX file with drawings [#1462](#1462),
- Fix Crash while trying setting a cell the value "123456\n" [#1476](#1481)
- Improved DATEDIF() function and reduced errors for Y and YM units [#1466](#1466)
- Stricter typing for mergeCells [#1494](#1494)

### Changed

- Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support
- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](#1445)
- Limit composer package to `src/` [#1424](#1424)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants