PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

add tests to support issue 4476

Open blizzz opened this issue 8 months ago • 1 comments

This is:

  • [ ] a bugfix
  • [ ] a new feature
  • [ ] refactoring
  • [X] additional unit tests

Checklist:

  • [ ] Changes are covered by unit tests
    • [ ] Changes are covered by existing unit tests
    • [ ] New unit tests have been added
  • [ ] Code style is respected
  • [X] Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • [ ] CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • [ ] Documentation is updated as necessary

Why this change is needed?

This test shall proof that a time is interpreted wrongly, at least with XLSX. Cf. https://github.com/PHPOffice/PhpSpreadsheet/pull/4479#issuecomment-2968328399

Screenshot_20250620_120113

blizzz avatar Jun 20 '25 10:06 blizzz

The test failure here is, as we already know, a consequence of floating point rounding. However, it can be coded to avoid a problem. You want the result to agree to minutes (and the same general discussion would apply if you wanted to agree to seconds). You can achieve that by doing the following before formatting the DateTime object:

Date::roundMicroseconds($dt);

oleibman avatar Jul 15 '25 06:07 oleibman