Re: New function: epoch_to_timestamp...

Поиск
Список
Период
Сортировка
От David Fetter
Тема Re: New function: epoch_to_timestamp...
Дата
Msg-id 20030815224115.GZ14335@fetter.org
обсуждение исходный текст
Ответ на Re: New function: epoch_to_timestamp...  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: New function: epoch_to_timestamp...  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, Aug 15, 2003 at 06:57:24AM -0400, Tom Lane wrote:
> David Fetter <david@fetter.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''''::intervalAS "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@fetter.org http://fetter.org/
phone: +1 510 893 6100    cell: +1 415 235 3778


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [GENERAL] 7.4Beta
Следующее
От: Jan Wieck
Дата:
Сообщение: Re: [GENERAL] 7.4Beta