basic/qa/basic_coverage/test_Time.bas                                   |   21 
++++++++++
 basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas |    2 
 basic/source/runtime/methods.cxx                                        |    5 
++
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 5a9c784cba996b599e36965d241509696d19ff3c
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu May 8 13:17:05 2025 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu May 8 15:15:36 2025 +0200

    tdf#136112: return 'Date' type from Time()
    
    Change-Id: Id21a4c378ddf9888740b3201f109e1897b722ded
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185046
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/basic/qa/basic_coverage/test_Time.bas 
b/basic/qa/basic_coverage/test_Time.bas
new file mode 100644
index 000000000000..b5de6dfba5d4
--- /dev/null
+++ b/basic/qa/basic_coverage/test_Time.bas
@@ -0,0 +1,21 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option Explicit
+
+Function doUnitTest as String
+  ''' Return 'text' OR 'date' variable '''
+
+  If (TypeName(Time$)<>"String" Or Vartype(Time())<>V_DATE) Then
+    doUnitTest = "FAIL" ' not successful
+  Else
+    doUnitTest = "OK" ' Ok
+  End If
+End Function
+
+Sub DEV_TST : MsgBox doUnitTest : End Sub
\ No newline at end of file
diff --git 
a/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas 
b/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas
index ac266475579b..0925fb3a0085 100644
--- a/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas
+++ b/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas
@@ -10,7 +10,7 @@ Option Explicit
 
 Function doUnitTest as String
     dim aDate as Date
-    aDate = Time()
+    aDate = Time$() ' Use string variant of the function, to limit precision 
to seconds
     ' CDateToUnoTime CDateFromUnoTime
     If ( CDateFromUnoTime( CDateToUnoTime( aDate ) ) <> aDate ) Then
         doUnitTest = "FAIL"
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 5d611ee23dd7..679414e10a14 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -2073,6 +2073,11 @@ void SbRtl_Time(StarBASIC *, SbxArray & rPar, bool 
bWrite)
     {
         tools::Time aTime( tools::Time::SYSTEM );
         SbxVariable* pMeth = rPar.Get(0);
+        if (!pMeth->IsString())
+        {
+            pMeth->PutDate(aTime.GetTimeInDays());
+            return;
+        }
         OUString aRes;
         if( pMeth->IsFixed() )
         {

Reply via email to