Date data type not supported by .setDataArray()

.setDataArray() fails with array members of type “Date”.
BASIC runtime error.
Object variable not set.

Is this intended behavior or a bug?
What is the BKM for setting array of cells from variant array with both date and string data type members?

Work around is to use .setData() or convert date to a long. Both of which have other undesireable side effects.

.setData() outputs strings as the value 0.

Converting date to long requires the cell/column be formated as date. Not such a big deal, except then other consumers of the date cell/column have to be changed to handle it as a long rather than a date.

REM  *****  BASIC  *****

Sub Main
	Dim arrVariant(1 to 1, 1 to 3) As Variant

	Dim date_x As Date: date_x = "2023-03-28"
	Dim long_x As Long: long_x = 2000000000
	Dim string_x As String: string_x = "This is a string"

	arrVariant(1,1) = date_x
'	arrVariant(1,1) = CLng(date_x)
	arrVariant(1,2) = long_x
	arrVariant(1,3) = string_x

	ThisComponent.Sheets.getByName("Sheet1").getCellRangeByName("A1:C1").setDataArray(arrVariant)
End Sub

https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XCellRangeData.html#abde435a89989ab90d13779c1ec49ca00

The size of the array must be the same as the size of the cell range. Each element of the array must contain a double or a string.

With a formulaArray you can set anything:

REM text, number, numeric text, date, blank, formula
rg = ThisComponent.Sheets(0).getCellRangeByPosition(0,0,5,0)
rg.setDataArray(Array(Array("abcd", 42, "0042", cLng(Date()), "", "=NOW()")))
rg = ThisComponent.Sheets(0).getCellRangeByPosition(0,1,5,1)
rg.setFormulaArray(Array(Array("abcd", "0042", "'0042", "2023-03-28", "", "=NOW()")))

This behavior is in keeping with the nature of Calc. A non-empty cell that does not contain a formula can have a value of type double or string. We see a number (double) as a date (time, boolean, currency, fraction, …) after the cell is formatted appropriately.

All about dates, times, date-times as strings, numbers, structs and how to deal with it in StarBasic