Bug 151460 - Calc: time data loose a second when dragged down
Summary: Calc: time data loose a second when dragged down
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.2.2 release
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.5.0 target:7.4.3
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-10 19:57 UTC by Lucio
Modified: 2023-02-10 10:45 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
screenshot of the Calc spreadsheet with the "incorrect" data (509.25 KB, application/pdf)
2022-10-10 20:04 UTC, Lucio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lucio 2022-10-10 19:57:58 UTC
Description:
Creating a date-hourly span time series; while dragging down the time changes from 00:00 minutes and seconds to 59:59 after circa 12 records. Either on MAC M1 Os12.5 and PC with Intel Core i7

Steps to Reproduce:
1. in a cell write a date with hours and minutes separated by column
2. in the lower cell write the same date with 1 more hour
3. drag down to at least 12 rows to have increment of 1 hour

Actual Results:
The value of the hour does not increment and the minutes and second become HH:59:59 as if had lost a second. Keep dragging to almost 30 rows one row return to HH:00:00 but 1 hour behind in respect to what expected

Expected Results:
The hour should have incremented and minutes and second had to stay 00:00


Reproducible: Always


User Profile Reset: No



Additional Info:
See the attachment, I have tried with a Mac OS12:5 and with a PC with WIN 10 Pro
Comment 1 Lucio 2022-10-10 20:04:09 UTC
Created attachment 182957 [details]
screenshot of the Calc spreadsheet with the "incorrect" data
Comment 2 Eike Rathke 2022-10-10 22:25:11 UTC
That is because date+time values are date serial numbers since the null-date as double floating point values.

Let's assume
A1: 2022-10-01 00:00:00.000
A2: 2022-10-01 01:00:00.000
with the underlying values (you can see when removing the date+time formatting)
A1: 44835
A2: 44835.0416666667

Due to the binary floating point representation the difference A2-A1 is 0.041666666700621136 and not 0.0416666666666667, so a little less than required.
Comment 3 Eike Rathke 2022-10-10 22:25:58 UTC
Let see if some scaling and rounding would do the trick..
Comment 4 Eike Rathke 2022-10-11 09:03:58 UTC
Actually it runs into approxDiff(), the raw diff would be 0.041666666664241347 and obtained is 0.041666666659999997
Comment 5 Commit Notification 2022-10-11 12:14:32 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/abd42a63f65f810c821085149c095682247e0d0d

Resolves: tdf#151460 Scale and round time diff fiddling with floating point

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Eike Rathke 2022-10-11 12:34:35 UTC
Pending review https://gerrit.libreoffice.org/c/core/+/141222 for 7-4
Comment 7 Commit Notification 2022-10-11 13:39:01 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/50baf45b122d4a0e32a5b63cfa5b51606b37bc9e

Resolves: tdf#151460 Scale and round time diff fiddling with floating point

It will be available in 7.4.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2022-10-12 19:05:51 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1b7356e57fbf28a62f10476cebbd45ee369fde17

tdf#151460: sc_ucalc: Add unittest

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.