Bug 51481 - FORMATTING: Calculating of time duration now fails if greater than 24 hours
Summary: FORMATTING: Calculating of time duration now fails if greater than 24 hours
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: BSA
Keywords: regression
Depends on:
Blocks:
 
Reported: 2012-06-27 10:03 UTC by Studio Firpo
Modified: 2012-06-29 10:30 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
an example, where one can input working days and parameters (pale yellow background), obtaining total working time (duration) in hours and minutes (pale green background) (10.70 KB, application/vnd.oasis.opendocument.spreadsheet)
2012-06-27 10:03 UTC, Studio Firpo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Studio Firpo 2012-06-27 10:03:17 UTC
Created attachment 63526 [details]
an example, where one can input working days and parameters (pale yellow background), obtaining total working time (duration) in hours and minutes (pale green background)

Problem description: 

Computing of duration greater than 24 hours, working correctly with previous versions, fails if duration is greater than 24 hours (format with square brackets).

Steps to reproduce:
1. Input one timestamp (beginning of time period)
2. Input one timestamp (end of time period)
3. Calculate duration (2. minus 1.)
4. Format duration with square brackets to avoid reconduction within 24 hours range

Current behavior:

duration will be calculated and displayed within 24 hours range

Expected behavior:

duration will be calculated and displayed with number of hours, even if beyond 24 hours range
Platform (if different from the browser): Fedora 17 x86_64, reproduced also on Windows Xp and Vista
              
Browser: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1
Comment 1 Eike Rathke 2012-06-27 12:38:48 UTC
Confirmed, taking.

Btw, your formula expression
=TIME(TRUNC((B$1*$B$4)/60,0),MOD(B$1*$B$4,60),0)
is overkill, date and time are expressed in days with 0.5==12h, so for your calculation in minutes this
=B1*B4/60/24
respectively
=B1*B4/1440
gives the same result.
Comment 2 Eike Rathke 2012-06-27 14:34:57 UTC
Use of the TIME() function actually provokes this.. TIME() was changed to return the time fraction only, so values between 0 (inclusive) and 1 (exclusive). Before 3.5.0 also the resulting day count was included. This change seems to be wrong.

So, if you use =B1*B4/1440 instead the calculation and display works as intended.
Comment 3 Eike Rathke 2012-06-27 16:56:23 UTC
So, having looked things up again, the TIME() function now behaves as defined in the ODF OpenFormula standard and returns only the fractional part. Excel does the same.
Comment 4 Studio Firpo 2012-06-28 02:53:51 UTC
Many thanks for Your prompt reply.

As I understand date/time calculations are going more and more into the direction of comfortable and modern calculation, without having to use dedicated functions.

But:
1. I had to change my formulas (previous work went lost)
2. as a matter of fact You based Your answer upon Your knowledge of internal structure
3. a "normal", daily user, perhaps should not be expected to know such deep details and anyway I found nowhere in the documentation hints to the new possibilities about date/time calculations

So, if I did not miss something, even if it is stated that "this is not a bug", it would be advisable to keep documentation as updated as possible.
Comment 5 Eike Rathke 2012-06-29 03:55:54 UTC
Just a side note: what you call new and modern calculation has always been possible. All spreadsheet applications like Excel, Gnumeric and Calc treat date/time values in this numeric floating point way in units of days.
Comment 6 Studio Firpo 2012-06-29 10:30:52 UTC
OK, I did not know about it. It has been a good opportunity to learn something new for me. Thank You.