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... "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
On Fri, Aug 15, 2003 at 06:57:24AM -0400, Tom Lane wrote:
> David Fetter  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@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
FAQ