2000-01-05 07:07:58 +01:00
|
|
|
--
|
|
|
|
-- ABSTIME
|
|
|
|
-- testing built-in time type abstime
|
|
|
|
-- uses reltime and tinterval
|
|
|
|
--
|
1997-04-05 13:08:30 +02:00
|
|
|
|
|
|
|
--
|
|
|
|
-- timezones may vary based not only on location but the operating
|
|
|
|
-- system. the main correctness issue is that the OS may not get
|
1997-04-27 04:58:38 +02:00
|
|
|
-- daylight savings time right for times prior to Unix epoch (jan 1 1970).
|
1997-04-05 13:08:30 +02:00
|
|
|
--
|
|
|
|
|
|
|
|
CREATE TABLE ABSTIME_TBL (f1 abstime);
|
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
BEGIN;
|
2001-11-21 19:27:25 +01:00
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
|
2001-09-28 10:00:11 +02:00
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
|
|
|
|
SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
|
|
|
|
END;
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
DELETE FROM ABSTIME_TBL;
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2001-09-28 10:00:11 +02:00
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
|
2000-01-05 07:07:58 +01:00
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
|
1997-04-05 13:08:30 +02:00
|
|
|
|
|
|
|
-- what happens if we specify slightly misformatted abstime?
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
|
|
|
|
|
|
|
|
-- badly formatted abstimes: these should result in invalid abstimes
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
|
|
|
|
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
|
|
|
|
|
|
|
|
-- test abstime operators
|
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS eight, * FROM ABSTIME_TBL;
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS six, * FROM ABSTIME_TBL
|
2000-01-05 07:07:58 +01:00
|
|
|
WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS six, * FROM ABSTIME_TBL
|
2000-01-05 07:07:58 +01:00
|
|
|
WHERE ABSTIME_TBL.f1 > abstime '-infinity';
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS six, * FROM ABSTIME_TBL
|
2000-01-05 07:07:58 +01:00
|
|
|
WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS three, * FROM ABSTIME_TBL
|
2000-01-05 07:07:58 +01:00
|
|
|
WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS four, * FROM ABSTIME_TBL
|
2000-01-05 07:07:58 +01:00
|
|
|
WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2005-04-07 03:51:41 +02:00
|
|
|
SELECT '' AS four, * FROM ABSTIME_TBL
|
1997-04-05 13:08:30 +02:00
|
|
|
WHERE ABSTIME_TBL.f1 <?>
|
2000-01-05 07:07:58 +01:00
|
|
|
tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
|
1997-04-05 13:08:30 +02:00
|
|
|
|
2000-09-14 17:55:07 +02:00
|
|
|
SELECT '' AS four, f1 AS abstime,
|
|
|
|
date_part('year', f1) AS year, date_part('month', f1) AS month,
|
|
|
|
date_part('day',f1) AS day, date_part('hour', f1) AS hour,
|
|
|
|
date_part('minute', f1) AS minute, date_part('second', f1) AS second
|
|
|
|
FROM ABSTIME_TBL
|
2001-09-28 10:00:11 +02:00
|
|
|
WHERE isfinite(f1)
|
2000-09-14 17:55:07 +02:00
|
|
|
ORDER BY abstime;
|