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

TEXT format with only time string returns 0 instead of the time #3409

Closed
2 of 9 tasks
lucasnetau opened this issue Feb 28, 2023 · 0 comments · Fixed by #3411
Closed
2 of 9 tasks

TEXT format with only time string returns 0 instead of the time #3409

lucasnetau opened this issue Feb 28, 2023 · 0 comments · Fixed by #3411

Comments

@lucasnetau
Copy link
Contributor

This is:

  • a bug report

What is the expected behavior?

Output of =TEXT("09:01","HH:MM:SS") is the time string 09:01:00

Verified with Excel and LibreOffice

What is the current behavior?

Output is 00:00:00

What features do you think are causing the issue

PhpOffice\PhpSpreadsheet\Calculation\TextData\Format::TEXTFORMAT uses DateTimeExcel\DateValue::fromString($value) to parse the text into a numeric value. In the case where only a time is provided DateValue::fromString returns (float)0.0

Possible fix is Format::TEXTFORMAT should check for the return of (float)0.0 and then hand off to DateTimeExcel\TimeValue::fromString($value) to get the correct numeric value

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Which versions of PhpSpreadsheet and PHP are affected?

Tested on PhpSpreadsheet 1.28 and PHP8.0

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 28, 2023
Fix PHPOffice#3409. Calculate both the date and time portions when a date/time format is supplied for the TEXT function.
@MarkBaker MarkBaker assigned MarkBaker and unassigned MarkBaker Feb 28, 2023
oleibman added a commit that referenced this issue Mar 2, 2023
Fix #3409. Calculate both the date and time portions when a date/time format is supplied for the TEXT function.
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