Starbasic 与 libreoffice API:
function GETSECONDS(s1 as string) as long
oFuncAccess = createUnoService( "com.sun.star.sheet.FunctionAccess" )
s1 = oFuncAccess.callFunction("SUBSTITUTE", array(s1, "days", "*24*60*60+"))
s1 = oFuncAccess.callFunction("SUBSTITUTE", array(s1, "hours", "*60*60+"))
s1 = oFuncAccess.callFunction("SUBSTITUTE", array(s1, "minutes", "*60+"))
s1 = oFuncAccess.callFunction("SUBSTITUTE", array(s1, "seconds", "*1+"))
s1 = left(s1, len(s1)-1)
lRes = 0
sAdd = split(s1, "+")
for i = lbound(sAdd) to ubound(sAdd)
sMult = split(sAdd(i),"*")
lResMult = 1
for j = lbound(sMult) to ubound(sMult)
lResMult = lResMult * val(sMult(j))
next
lRes = lRes + lResMult
next
getSeconds = lRes
end function
用作 UDF,如:=GETSECONDS(A1)
时间测量单位必须是复数形式。
问候
阿克塞尔