Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7b06d99

Browse files
author
Thomas G. Lockhart
committed
Backend code redefinitions to allow read/write
of integer Unix system times.
1 parent8d30b40 commit7b06d99

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

‎contrib/unixdate/unixdate.sql

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- unixdate
2+
-- Routines to convert int4 (Unix system time) to datetime
3+
-- and int4 (delta time) to timespan
4+
--
5+
-- Thomas Lockhart (lockhart@alumni.caltech.edu)
6+
-- 1997-11-25
7+
--
8+
-- This cheats and reuses existing code in the standard package.
9+
-- Can not include this directly because built-in functions are optimized
10+
-- into a cache and the duplicate function names abstime_datetime() and
11+
-- reltime_timespan() result in duplicate constants.
12+
--
13+
-- This works with Postgres v6.2 and higher.
14+
15+
--
16+
-- Conversions from integer to datetime
17+
--
18+
19+
CREATEFUNCTIONabstime_datetime(int4)
20+
RETURNS datetime
21+
AS'-' LANGUAGE'internal';
22+
23+
CREATEFUNCTIONdatetime(int4)
24+
RETURNS datetime
25+
AS'select abstime_datetime($1)' LANGUAGE'SQL';
26+
27+
CREATEFUNCTIONreltime_timespan(int4)
28+
RETURNS timespan
29+
AS'-' LANGUAGE'internal';
30+
31+
CREATEFUNCTIONtimespan(int4)
32+
RETURNS timespan
33+
AS'select reltime_timespan($1)' LANGUAGE'SQL';
34+
35+
--
36+
-- Conversions back to integer
37+
--
38+
39+
CREATEFUNCTIONdatetime_abstime(datetime)
40+
RETURNS int4
41+
AS'-' LANGUAGE'internal';
42+
43+
CREATEFUNCTIONutime(datetime)
44+
RETURNS int4
45+
AS'select datetime_abstime($1)' LANGUAGE'SQL';
46+
47+
CREATEFUNCTIONtimespan_reltime(timespan)
48+
RETURNS int4
49+
AS'-' LANGUAGE'internal';
50+
51+
CREATEFUNCTIONuspan(timespan)
52+
RETURNS int4
53+
AS'select timespan_reltime($1)' LANGUAGE'SQL';
54+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp