From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: New function: epoch_to_timestamp... |
Date: | 2003-08-15 22:41:15 |
Message-ID: | 20030815224115.GZ14335@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Aug 15, 2003 at 06:57:24AM -0400, Tom Lane wrote:
> David Fetter <david(at)fetter(dot)org> 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 david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2003-08-16 04:27:25 | Re: [GENERAL] 7.4Beta |
Previous Message | Bruce Momjian | 2003-08-15 22:17:33 | Re: [GENERAL] 7.4Beta |