On Fri, Aug 15, 2003 at 06:57:24AM -0400, Tom Lane wrote:
> David Fetter <[EMAIL PROTECTED]> writes:
> > 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?

> The return type should be timestamptz, which makes the
> transformation timezone-independent.

Do you mean the default one should read as follows, or that the
default one should take params (integer, output_timezone,
input_timezone), or...?

CREATE OR REPLACE FUNCTION epoch_to_timestampz (INTEGER)
RETURNS TIMESTAMPZ AS '
DECLARE
    the_sql  TEXT;
    the_record RECORD;
    the_time TIMESTAMPZ;
BEGIN
    the_sql := ''SELECT ''''January 1 1970''''::timestamp + ''''''
             || $1
             || '' seconds''''::interval AS "foo"'';
    RAISE NOTICE ''%'', the_sql;
    FOR the_record IN EXECUTE the_sql LOOP
        the_time := the_record.foo;
    END LOOP;
    RETURN the_time;
END;
' LANGUAGE 'plpgsql';

Cheers,
D
-- 
David Fetter [EMAIL PROTECTED] http://fetter.org/
phone: +1 510 893 6100    cell: +1 415 235 3778

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to