Bug 76549

Summary: Other: Date shown with wrong day using different format
Product: LibreOffice Reporter: fsoltrash <fsoltrash>
Component: CalcAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED NOTABUG    
Severity: normal CC: fsoltrash, jmadero.dev, miguelangelrv
Priority: medium    
Version: 4.1.5.3 release   
Hardware: Other   
OS: Linux (All)   
Whiteboard: BSA
Crash report or crash signature: Regression By:
Attachments: Sample file

Description fsoltrash 2014-03-24 10:42:43 UTC
Created attachment 96283 [details]
Sample file

Problem description: The problem emerged in a file similar to the one attached. There is a column where each row is a date obtained by adding 15 minutes to the preceding one. The following columns contain references to the original date using different formats (the first two use the TEXT function, the other two are direct references). In the first rows the dates are shown correctly, but after about 2500 rows, when the first row starts a new day, the columns that are formatted to display just date are showing a different day than the ones that are formatted showing both date and hour.

I tried on a windows machine using an older LibreOffice release (3.6.5) and it shows the difference from the first row. This is a more consistent and reliable behaviour but in my opinion still not correct, since a date refers to the same day even when formatted in a different way.

Steps to reproduce:
1.Open the attached file
2.Look at row 2499


Current behavior: References to the same date are showing different day when formatted in a different way.

Expected behavior: Dates shown with different formats should still refer to the initial day

              
Operating System: Ubuntu
Version: 4.1.5.3 release
Comment 1 m_a_riosv 2014-03-24 18:10:22 UTC
Hi fsoltrash, thanks for reporting.

Even it seems, there is not a bug.

The value in B2499 is 41665,999999994 not 41666,00000000000.
As you aren't rounding the +1/24/4 an error is accumulated.

In B2499 you are showing the time, so the format round the time and in consequence the day, so it shows 27/01/14 00:00. But if you set up here a format like DD/MM/YY it shows 26/01/14.

The text formula in C2499 doesn't show the hour, so as it must be it takes only the day, integer part of the value is 41665, that correspond to 26/01/14. If you add the hours to text function shows the same as B2499.

To obtain an accurate value for the whole year, use a formula like:

B4: =ROUND(B3+1/24/4;10)

Changed status to resolve notabug, please if you are not agree, reopen it.
Comment 2 fsoltrash 2014-03-25 08:09:03 UTC
I'm reopening this as I'm still not convinced this is a correct behaviour.
I was aware that the issue is caused by some kind of accumulation of rounding error, but the problem in my opinion is in the way the date is rounded according the different format. Does it make sense to round a date/time in a different way if it also shows the time? In my opinion not. 
The day of a date should stay the same even if I am not showing the time. In effect I also think it doesn't make sense to round a date (at least not by default). 
This behaviour also silently break compatibility with excel. In fact I came across the problem trying to understand why I got inconsistent results while migrating an old xls file.
Comment 3 Joel Madero 2014-05-01 04:07:46 UTC
Yes this is not a bug - if I can dig out Kohei's explanation of this I'll try to but it's been explained quite a few times about these rounding issues that are just unavoidable