Bug 136112 - Basic Time function returns inconsistent datatype
Summary: Basic Time function returns inconsistent datatype
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0
Keywords:
Depends on:
Blocks: Macro-VBA Macro-StarBasic
  Show dependency treegraph
 
Reported: 2020-08-25 14:25 UTC by Alain Romedenne
Modified: 2022-09-10 03:50 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alain Romedenne 2020-08-25 14:25:37 UTC
Description:
Time and Time$ both return a String, while the former should return a Variant (Date) which would be consistent with VBA.

Time should be documented as a function - not as a statement - as changing time on Unix platforms requires admin privilege. Time statement does not function under Windows and should therefore be marked as unsupported. 

Steps to Reproduce:
1. Example Basic code:
Private Sub _Time_
	CompatibilityMode(True)
	Print TypeName(Time()), VarType(Time), TypeName(Time$), VarType(Time$())
	Time = "18:20:15" ' does nothing
	CompatibilityMode(False)
End Sub
2. Run and observe the routine results


Actual Results:
Time$ returns a locale-dependant String output
Time  returns a locale-dependant String output

Expected Results:
Time$ to return a locale-dependant String output
Time to return a Variant of Type 7 (Date/Time)


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.4.4.2 (x64)
Build ID: 3d775be2011f3886db32dfd395a6a6d1ca2630ff
CPU threads: 12; OS: Windows 10.0 Build 17134; UI render: default; VCL: win; 
Locale: en-GB (en_IE); UI-Language: en-GB
Calc: threaded
Comment 1 Andreas Heinisch 2020-09-02 10:20:29 UTC
Confirmed in:

Version: 6.3.0.0.beta1 (x64)
Build-ID: a187af327633f5f00363be5131bd21a13e0f1a7b
CPU-Threads: 4; BS: Windows 10.0; UI-Render: GL; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc: CL

However, Time$ does not return a locale-dependent String:
https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods.cxx?r=40031dd4#2239
Comment 3 Alain Romedenne 2020-09-03 08:53:54 UTC
As opposed to Time function, Date[$] function behaves consistently:

- Date returns a Variant
- Date$ returns a String

Similarly to Time function, Date should be documented as function instead of a statement. As platform date updates are restricted to worksattion admins.
Comment 4 Alain Romedenne 2020-09-03 08:58:00 UTC
REM  *** DATE FUNCTION EXAMPLE ***

Sub _Date_
	Print Date, TypeName(Date()), VarType(Date), Date$, TypeName(Date$), VarType(Date$())
	Date = "February 12, 1985" ' does nothing
End Sub

- VBA Date function
  https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/date-function
- VBA Date statement
  https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/date-statement
Comment 5 Commit Notification 2020-09-03 16:20:43 UTC
Alain Romedenne committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/5b2fdb324ae69febd7af11b10ce6882d98894ebd

tdf#136112 Date/Time are LibO Basic functions not statements
Comment 6 Commit Notification 2020-09-08 15:19:02 UTC
Alain Romedenne committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c3c8d2d67174beddb27fc94b10aebed259500133

tdf#136112 Unit test for Date() Basic function

It will be available in 7.1.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 7 Alain Romedenne 2020-09-09 16:16:48 UTC
Suggestion for a QA unit test routine:

Function doUnitTest as Integer
  ''' Return 'text' OR 'date' variable '''

  If ( TypeName(Time$)<>"String" Or Vartype(Time())<>V_DATE ) Then
    doUnitTest = 0 ' not successful
  Else
    doUnitTest = 1 ' Ok
  End If
End Function

Sub DEV_TST : MsgBox doUnitTesT : End Sub
Comment 8 QA Administrators 2022-09-10 03:50:45 UTC
Dear Alain Romedenne,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug