Kind people,
After discussing this w/Josh yesterday, I'd like to propose a new
function for date_time. Here's the Pl/PgSQL version, warts 'n' all.
CREATE OR REPLACE FUNCTION epoch_to_timestamp (INTEGER)
RETURNS TIMESTAMP AS '
DECLARE the_sql TEXT; the_record RECORD; the_time TIMESTAMP;
BEGIN the_sql := ''SELECT ''''January 1 1970''''::timestamp + '''''' || $1 || ''
seconds''''::intervalAS "foo"''; FOR the_record IN EXECUTE the_sql LOOP the_time := the_record.foo; END LOOP;
RETURN the_time;
END;
' LANGUAGE 'plpgsql';
My C skills (Hello, world!) aren't up to doing it that way, although
that's probably The Right Thing(TM). Is there a reasonable way to add
an optional param or two to mark time zones, or should that just the
application programmer's hassle?
TIA for any feedback :)
Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778