Bug 118800 - HOUR, MINUTE and SECOND function return value that is 1 too high, when seconds value of time >= 59.5 (HOUR, MINUTE) or >= xx.5 (SECOND)
Summary: HOUR, MINUTE and SECOND function return value that is 1 too high, when secon...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: Winfried Donkers
URL:
Whiteboard: target:6.2.0 target:6.1.0.2 target:6....
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2018-07-17 13:19 UTC by Dmitro
Modified: 2018-09-06 15:52 UTC (History)
4 users (show)

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 Dmitro 2018-07-17 13:19:58 UTC
Description:
Issue is reproduced for all input types.

Steps to Reproduce:
1.Open LibreOffice Calc
2.Enter following formulas to any cell
=HOUR(-0.000001)

Actual Results:
24


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
Version: 6.0.6.1 (x64)
Build ID: dc68ad6c5cde3c62874b96422f2e5e8252499bad
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: en-US (en_US); Calc: group
Comment 1 raal 2018-07-17 20:29:59 UTC
definition 6.10.10 HOUR
Summary: Extracts the hour (0 through 23) from a time.
Syntax: HOUR( TimeParam T )
Returns: Number
Constraints: None
Semantics: Extract from T the hour value, 0 through 23, as per a 24-hour clock. This is equal to:
DayFraction=(T-INT(T))
Hour=INT(DayFraction*24)

confirm with Version: 6.2.0.0.alpha0+
Build ID: d11313f341d1d9a9c73c736932441a89d5292e37
CPU threads: 4; OS: Linux 4.4; UI render: default; VCL: gtk3;
Comment 2 Winfried Donkers 2018-07-18 17:44:15 UTC
There is a rounding error in the code.
For example, =HOUR("10:59:59.6") returns 11, whereas it should return 10.

I will fix it.
Comment 3 Winfried Donkers 2018-07-18 17:49:34 UTC
Likewise, =MINUTE("10:20:59.6") returns 21 instead of 20, and 
=SECOND("10:30:59.6") return 0 instead of 59.
Comment 4 Xisco Faulí 2018-07-18 18:31:29 UTC
Also reproduced in

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 5 Commit Notification 2018-07-19 12:02:44 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c69e7266916ac1b8917477fb4eccdb9098da5792

tdf#118800 fix rounding error in Calc function HOUR, MINUTE, SECOND.

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2018-07-19 17:28:34 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=bda9288ffee552b55eed9dbf02e1204957bd4513&h=libreoffice-6-1

tdf#118800 fix rounding error in Calc function HOUR, MINUTE, SECOND.

It will be available in 6.1.0.2.

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

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2018-08-27 22:16:34 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=273b3e10eab70ebc084cb62568bd699fddfb376e

Resolves: tdf#119533 reintroduce time rounding but cut, tdf#118800 follow-up

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2018-08-28 10:50:24 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=98cb91686901dc0133c5c23dc5658d9623dbd436

Shortcut small negative values to 0:0:0, tdf#119533 tdf#118800 follow-up

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2018-09-04 08:01:38 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=184aee6abd202f6f4e2c18d21f96a0d1a9fd947f&h=libreoffice-6-1

Resolves: tdf#119533 reintroduce time rounding but cut, tdf#118800 follow-up

It will be available in 6.1.2.

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

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2018-09-06 15:52:09 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-1-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=34887e7a8d36603ade1a0621d511906b826d0298&h=libreoffice-6-1-1

Resolves: tdf#119533 reintroduce time rounding but cut, tdf#118800 follow-up

It will be available in 6.1.1.

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

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