Files
loongoffice/basic/qa/basic_coverage/test_format_function.bas
Mike Kaganski d1c9252bf3 tdf#166342: refactor SbxValue::Format again, to handle date/time strings
Commit 81e1e0a2a671f19950c1bd3c69f9aa24b0c562e7 changed string-to-number
procedure from SvNumberFormatter to only use SbxValue::ScanNumIntnl. But
the latter can only handle strings with simple numbers, not with dates,
times and the like.

This change restores use of SvNumberFormatter to convert input strings
to number, when SbxValue::ScanNumIntnl fails. The code is re-structured
for performance, to avoid creating SvNumberFormatter twice, and repeated
calls to GetOUString.

Change-Id: I89a4fc041fe24fe00b099ab4fbee371d1f6b5567
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185047
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 33434f16206aaa07f56af8f4c23b05b3c88a2124)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185065
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-05-15 16:35:05 +02:00

29 lines
834 B
QBasic

'
' 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
TestUtil.TestInit
verify_testFormat
doUnitTest = TestUtil.GetResult()
End Function
Sub verify_testFormat
On Error GoTo errorHandler
Dim d As Date
d = "2024-09-16 17:03:30"
TestUtil.AssertEqual(Format(d, "YYYY-MM-DD"), "2024-09-16", "Format(d, ""YYYY-MM-DD"")")
TestUtil.AssertEqual(Format("2024-09-16 05:03:30 PM", "hh-mm-ss"), "17-03-30", "Format(""2024-09-16 05:03:30 PM"", ""hh-mm-ss"")")
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testFormat", Err, Error$, Erl)
End Sub