Bug 133389 - Date & time functions in StarBasic and Calc return different results
Summary: Date & time functions in StarBasic and Calc return different results
Status: RESOLVED WORKSFORME
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: 2024-08-03 17:23 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?
Comment 4 QA Administrators 2022-11-19 03:35:40 UTC Comment hidden (obsolete)
Comment 5 Mike Kaganski 2024-08-03 16:53:39 UTC
All numbers in row 15 are equal now in all columns, using Version: 24.8.0.2 (X86_64) / LibreOffice Community
Build ID: 57ceca7d2eefdf83e7c9b4135a017f3361a8133f
CPU threads: 24; OS: Windows 11 X86_64 (10.0 build 26100); UI render: default; VCL: win
Locale: en-US (ru_RU); UI: en-US
Calc: CL threaded.
WORKSFORME.
Comment 6 Mike Kaganski 2024-08-03 17:23:12 UTC
FTR: also works correctly using Version: 24.2.4.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 24; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (C.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.4~rc2-0ubuntu0.22.04.1~lo1
Calc: threaded

Note that hard recalculation might be needed first, to update cached formula results.