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

DateTime 4 years difference because Date::setExcelCalendar #1635

Closed
ybelenko opened this issue Sep 1, 2020 · 1 comment · Fixed by #4071
Closed

DateTime 4 years difference because Date::setExcelCalendar #1635

ybelenko opened this issue Sep 1, 2020 · 1 comment · Fixed by #4071

Comments

@ybelenko
Copy link

ybelenko commented Sep 1, 2020

This is:

- [ ] a bug report
- [x] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

I've spent almost 5 hours to investigate weird bug. I've made a small parser application and covered it with unit tests. I didn't understand why my assert of DateTimes fails when I add new test to completely unrelated class. As it turned out PHPUnit runs all tests simultaneously, so if one test contains reading of file in .numbers format and second test handles .xlsx then the PhpOffice\PhpSpreadsheet\Shared\Date::$excelCalendar value will be self::CALENDAR_WINDOWS_1900 for both tests which is wrong.

What is the expected behavior?

I don't know how to fix this issue with current class architecture, it's obviously you cannot switch from static method to internal one.

What is the current behavior?

When I load Mac file and then Win file I expect to calculate DateTime from Mac file correctly.

What are the steps to reproduce?

  1. Load spreadsheet A file created on Windows system.
  2. Load spreadsheet B file created on Mac system.
  3. Get value from datetime cell of the file A and convert it to DateTime with Date::excelToDateTimeObject method. Resulted DateTime instance will be different from original file(4 years different to be more specific).

Which versions of PhpSpreadsheet and PHP are affected?

  • PHP 7.4.6 (cli) (built: May 28 2020 23:40:38) ( NTS )
  • "phpoffice/phpspreadsheet": "^1.14"
@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants