Bug 124303 - Formatting [HH]:mm sometimes looses a second
Summary: Formatting [HH]:mm sometimes looses a second
Status: RESOLVED DUPLICATE of bug 122991
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.2.0.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-24 06:40 UTC by Martin Atke Bentsen
Modified: 2019-03-24 06:50 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Atke Bentsen 2019-03-24 06:40:11 UTC
Description:
Using the [HH] formatting can result in some inapropriate floorings of the underlying double value of a datetime, loosing a second, that can propagate up to loosing a minute or an hour. Quite problematic when using LibreCalc to calculate saleries of hourly paid employees. Using HH (without the brackets), there is proper rounding to avoid this precision problem of floats to propagate up to loosing a second. See steps to reproduce.

Steps to Reproduce:
1. In cell A1 write 17:   (will show 17:00:00)
2. In cell B1 write 21:   (will show 21:00:00)
3. In cell C1 write =B1-A1   (will show 04:00:00   correct)
4. Change format of C1 to: [HH]:mm  (will show 03:59   wrong)
5. Change format of C1 to: [HH]:MM:SS.000000000000000 (will show 03:59:59.999999999996362   wrong)
6. Change format of C1 to: HH:MM:SS.000000000000000 (will show 04:00:00.000000000000000   correct, but wont work as [HH] when above 24 hours)


Actual Results:
03:59

Expected Results:
04:00


Reproducible: Always


User Profile Reset: Yes



Additional Info:
I think this problem started around v4, and is still a problem i v6. Was not a problem in some old v3.

A workaround i have been using is to add a second, that is then rounded of when only showing minutes. Like in reproduce example, in C1 write: 
=B1-A1+"00:00:01"   
and format [HH]:mm
Comment 1 Mike Kaganski 2019-03-24 06:50:40 UTC

*** This bug has been marked as a duplicate of bug 122991 ***