Bug 133389 - Date & time functions in StarBasic and Calc return different results
Summary: Date & time functions in StarBasic and Calc return different results
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.4.3.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2020-05-25 19:27 UTC by Albrecht Müller
Modified: 2020-11-18 22:08 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file demonstrating different results of date & time functions (26.30 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-05-25 19:34 UTC, Albrecht Müller
Details
Example file demonstrating different results of date & time functions update (82.33 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-06-01 17:39 UTC, Albrecht Müller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Albrecht Müller 2020-05-25 19:27:13 UTC
Description:
Bug 132083 shows an unexpected result of a simple date & time calculation. If you feed the very same values into the date & time functions of Calc and StarBasic you will get different results.



Steps to Reproduce:
Open the attachted example file in a context that allows the execution of macros.

Actual Results:
The Calc version of the MINUTE function returns a 9 minutes difference, the StarBasic version 10 minutes.

Expected Results:
Both versions of the MINUTE function should return 10 minutes as this is the difference between 18 and 8.


Reproducible: Always


User Profile Reset: No



Additional Info:
Calc Version: 6.4.3.2, Build-ID: 1:6.4.3-0ubuntu0.20.04.1, CPU-Threads: 4; BS: Linux 5.4; UI-Render: Standard; VCL: gtk3; Gebietsschema: de-DE (de_DE.UTF-8); UI-Sprache: de-DE, Calc: threaded
Comment 1 Albrecht Müller 2020-05-25 19:34:36 UTC
Created attachment 161278 [details]
Example file demonstrating different results of date & time functions
Comment 2 Eike Rathke 2020-05-25 21:31:08 UTC
The usual confusion of timestamp and duration. The example applies the non-rounding MINUTE() wall clock / timestamp spreadsheet function on a time difference or duration value with a slight imprecision.

  =A5*24     => 0.166666666388889
  =A5*24*60  => 9.99999998333333

I don't know if there is a standard definition (VBA?) for the BASIC Minute() function, but the spreadsheet MINUTE() function is defined to not round, see https://docs.oasis-open.org/office/OpenDocument/v1.3/cs01/part4-formula/OpenDocument-v1.3-cs01-part4-formula.html#MINUTE

The difference between not-/rounding is also visible by applying the HH:MM:SS wall clock number format (00:09:59) instead of the correct [HH]:MM:SS duration format (00:10:00) on A5.
Comment 3 Albrecht Müller 2020-06-01 17:39:03 UTC
Created attachment 161500 [details]
Example file demonstrating different results of date & time functions  update

(In reply to Eike Rathke from comment #2)
> The usual confusion of timestamp and duration.

Did I get timestamp and duration right this time?