Issue 65555 - Basic function does not accept variants
Summary: Basic function does not accept variants
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All Unix, all
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-18 20:24 UTC by villeroy
Modified: 2017-05-20 11:29 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description villeroy 2006-05-18 20:24:28 UTC
The following fails at last step because Date2ISO insists on getting an object.
Surprisingly boolean TestStruct(v) works fine:
Sub Main
Dim oDt as new com.sun.star.util.Date
oDt.Year = 2000
oDt.Month = 12
oDt.Day =31
print TestStruct(oDt)
print TestStruct(0)
print IsoFromDateStruct(oDt)
print IsoFromDateValue(39000)
print Date2ISO(oDt)
print Date2ISO(39000)
End Sub
Function TestStruct(v)as boolean
Dim bResult as Boolean
If isUnoStruct(v) then
	bResult= true
Else
	bResult = false
EndIf
TestStruct = bResult
End Function

Function Date2ISO(vDt) as String
'conversion to basic-date dtVal
If isUnoStruct(vDt)Then 'object/UNO-struct
  dtVal = dateSerial(vDt.year,vDt.month,vDt.day)
Else
  dtVal = cDate(vDt)
End If
	sDt = cDateToISO(cDate(dtVal))
	Date2ISO = left(sDt,4)&"-"& mid(sDt,5,2)&"-"& right(sDt,2)
End Function


'pass a number or date-string
Function IsoFromDateValue(vDt)as string
Dim sDt$
	sDt = cDateToISO(cDate(vDt))
	IsoFromDateValue = left(sDt,4)&"-"& mid(sDt,5,2)&"-"& right(sDt,2)
End Function
'pass an UNO-struct com.sun.star.util.Date or DateTime.
Function IsoFromDateStruct(oDt as Object)as string
Dim dtVal as Date
	If isUNOStruct(oDt) then
		dtVal = DateSerial(oDt.Year,oDt.Month,oDt.Day)
		IsoFromDateStruct = IsoFromDateValue(dtVal)
	endif
End Function
Comment 1 Mathias_Bauer 2006-05-24 11:58:03 UTC
Sorry, I can't find any attached patch file so I change the type to "defect".
Andreas, I send this issue to you but it still needs confirmation.
Comment 2 ab 2006-05-24 12:33:38 UTC
Problem: Using vDt as object in

If isUnoStruct(vDt)Then 'object/UNO-struct
  dtVal = dateSerial(vDt.year,vDt.month,vDt.day)
Else
  ...

makes the compiler believe the symbol vDt is an object in any case.
This is wrong and leads to very confusing errors -> P3, 2.x, STARTED
Comment 3 ab 2006-08-21 09:19:30 UTC
-> OOo 2.1
Comment 4 ab 2006-10-16 16:39:06 UTC
According to discussion with mba/kso -> 2.2 as cws ab30
has to be integrated very soon.
Comment 5 ab 2007-01-02 14:12:51 UTC
2.x due to limited resources.
Has to be evaluated and targeted together with all other 2.x tasks.
Comment 6 Mathias_Bauer 2007-12-04 14:57:38 UTC
basic and scripting issues now should be assigned to component "scripting"
Comment 7 Martin Hollmichel 2007-12-07 12:13:44 UTC
set target to 3.x according to http://wiki.services.openoffice.org/wiki/Target_3x
Comment 8 T. J. Frazier 2009-12-11 21:11:49 UTC
Because an unhappy user cited this bug on the dev ml, I comment that this
antique bug has a simple workaround, entirely thanks to ab's insightful
analysis. If the parser is messing up, give it a different variable to mess up
on (and don't use that again).

The following version of function Date2ISO appears to run correctly; the
original version produces a run-time error.

Function Date2ISO(vDt) as String
'conversion to basic-date dtVal
If isUnoStruct(vDt)Then 'object/UNO-struct
'  dtVal = dateSerial(vDt.year,vDt.month,vDt.day)
  vW = vDt	'work around compiler bug 65555
  dtVal = dateSerial(vW.year,vW.month,vW.day)
Else
  dtVal = cDate(vDt)
End If
	sDt = cDateToISO(cDate(dtVal))
	Date2ISO = left(sDt,4)&"-"& mid(sDt,5,2)&"-"& right(sDt,2)
End Function
Comment 9 Marcus 2017-05-20 11:29:57 UTC
Reset assigne to the default "issues@openoffice.apache.org".