mirror of
https://github.com/postgres/postgres.git
synced 2025-07-24 14:22:24 +03:00
contrib
apache_logging
array
datetime
earthdistance
findoidjoins
fulltextindex
int8
isbn_issn
linux
lo
mSQL-interface
miscutil
noupdate
os2client
pginterface
soundex
spi
string
unixdate
unixdate.sql
userlock
README
doc
src
COPYRIGHT
HISTORY
INSTALL
README
register.txt
to integer unix system time conflict on the input types. Leave in the conversions from integer unix system time to datetime.
35 lines
931 B
SQL
35 lines
931 B
SQL
-- unixdate
|
|
-- Routines to convert int4 (Unix system time) to datetime
|
|
-- and int4 (delta time in seconds) to timespan
|
|
--
|
|
-- Thomas Lockhart (lockhart@alumni.caltech.edu)
|
|
-- 1997-11-25
|
|
--
|
|
-- This cheats and reuses existing code in the standard package.
|
|
-- Can not include this directly because built-in functions are optimized
|
|
-- into a cache and the duplicate function names abstime_datetime() and
|
|
-- reltime_timespan() would result in duplicate constants.
|
|
--
|
|
-- This works with Postgres v6.2 and higher.
|
|
|
|
--
|
|
-- Conversions from integer to datetime
|
|
--
|
|
|
|
CREATE FUNCTION abstime_datetime(int4)
|
|
RETURNS datetime
|
|
AS '-' LANGUAGE 'internal';
|
|
|
|
CREATE FUNCTION datetime(int4)
|
|
RETURNS datetime
|
|
AS 'select abstime_datetime($1)' LANGUAGE 'SQL';
|
|
|
|
CREATE FUNCTION reltime_timespan(int4)
|
|
RETURNS timespan
|
|
AS '-' LANGUAGE 'internal';
|
|
|
|
CREATE FUNCTION timespan(int4)
|
|
RETURNS timespan
|
|
AS 'select reltime_timespan($1)' LANGUAGE 'SQL';
|
|
|