====== pears.numtotime ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."numtotime"( in "thenum" decimal(5,2) )
returns time
begin
declare "rv" time;
declare "ss" char(5);
declare "ii" smallint;
declare "num1" decimal(5,2);
declare "num2" decimal(5,2);
set "num1" = "floor"("thenum");
set "num2" = "thenum"-"num1";
if "thenum" >= 24 or "thenum" < 0 then
set "num1" = 23;
set "num2" = .59
end if;
if "num2" > .59 then
set "num2" = .59
end if;
set "thenum" = "num1"+"num2";
set "ss" = "thenum";
set "ii" = "locate"("ss",'.');
if "ii" = 0 then
set "ss" = "ss"+':00'
else
if "ii" = 1 then
set "ss" = '0' || "ss";
set "ii" = 2
end if;
set "ss" = "left"("ss","ii"-1)+':'+"substr"("ss","ii"+1,2)
end if;
set "rv" = "ss";
return("rv")
end