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

Date (re-)import shenanigans #1440

Open
blizzz opened this issue Nov 5, 2024 · 2 comments
Open

Date (re-)import shenanigans #1440

blizzz opened this issue Nov 5, 2024 · 2 comments
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working

Comments

@blizzz
Copy link
Member

blizzz commented Nov 5, 2024

Steps to reproduce

  1. Create a table with a Datetime field
  2. Export the table to csv
  3. Create a new table by importing the file. Make sure to set the column type to DateTime during import.

Expected behavior

New table content is like old table content

Actual behavior

The import fails, because the date cannot be parsed, for it is in an unexpected format:

floor(): Argument #1 ($num) must be of type int|float, string given","Code":0,"Trace":[{"file":"/srv/http/nextcloud/master/apps-repos/tables/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/Date.php","line":224

In one place we run \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject() without testing the input value. The method assumes it is a float or int. More precisely it expects a Microsoft Excel timestamp like 42495.15902, but a string in the form of "2024-02-24".

Also I am not sure the detection works, either, for Date::isDateTime() is being called and it does not test for the mentioned timestamp.

Tables app version

main

Browser

No response

Client operating system

No response

Operating system

No response

Web server

None

PHP engine version

None

Database

None

Additional info

Actually, I am not sure how important it is to check for this type. It might be with xlsx formats, I have not tried it out yet. At some point, there migth be collisions between unix timestamps and MS Excel timestamps and it is not possible to tell them apart – though the file type can be taken into account.

For example, 42495 is roughly quarter to 1pm on 01.01.1970 in UNIX, but 0.00 o'clock on May 5th 2016 in Excel.

I have local changes trying to tame this to some degree, but not every case is covered yet.

cc @luka-nextcloud if you have insights.

@blizzz blizzz added 0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending approval or rejection. This issue is pending approval. labels Nov 5, 2024
@blizzz
Copy link
Member Author

blizzz commented Nov 5, 2024

Related to #971

@blizzz
Copy link
Member Author

blizzz commented Nov 8, 2024

For the record, in xlsx files, the date is stored in the excel format, and import is possible from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant