Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* timestamp.h
|
|
|
|
* Definitions for the SQL92 "timestamp" and "interval" types.
|
|
|
|
*
|
2003-08-04 04:40:20 +02:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2004-05-21 07:08:06 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.37 2004/05/21 05:08:05 tgl Exp $
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TIMESTAMP_H
|
|
|
|
#define TIMESTAMP_H
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <limits.h>
|
2000-06-15 02:52:26 +02:00
|
|
|
#include <float.h>
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2000-06-09 03:11:16 +02:00
|
|
|
#include "fmgr.h"
|
2004-05-21 07:08:06 +02:00
|
|
|
#include "pgtime.h"
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
#include "utils/int8.h"
|
|
|
|
#endif
|
2000-06-09 03:11:16 +02:00
|
|
|
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
/*
|
|
|
|
* Timestamp represents absolute time.
|
|
|
|
* Interval represents delta time. Keep track of months (and years)
|
|
|
|
* separately since the elapsed time spanned is unknown until instantiated
|
|
|
|
* relative to an absolute time.
|
|
|
|
*
|
|
|
|
* Note that Postgres uses "time interval" to mean a bounded interval,
|
2002-04-23 17:45:30 +02:00
|
|
|
* consisting of a beginning and ending time, not a time span - thomas 97/03/20
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
*/
|
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
|
|
|
typedef int64 Timestamp;
|
|
|
|
typedef int64 TimestampTz;
|
2002-09-04 22:31:48 +02:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
#else
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
typedef double Timestamp;
|
2001-09-28 10:09:14 +02:00
|
|
|
typedef double TimestampTz;
|
2002-04-21 21:52:18 +02:00
|
|
|
#endif
|
2001-09-28 10:09:14 +02:00
|
|
|
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
2002-09-04 22:31:48 +02:00
|
|
|
int64 time; /* all time units other than months and
|
|
|
|
* years */
|
2002-04-21 21:52:18 +02:00
|
|
|
#else
|
2002-09-04 22:31:48 +02:00
|
|
|
double time; /* all time units other than months and
|
|
|
|
* years */
|
2002-04-21 21:52:18 +02:00
|
|
|
#endif
|
2002-09-04 22:31:48 +02:00
|
|
|
int32 month; /* months and years, after time for
|
|
|
|
* alignment */
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
} Interval;
|
|
|
|
|
|
|
|
|
2002-08-04 08:42:18 +02:00
|
|
|
#define MAX_TIMESTAMP_PRECISION 6
|
|
|
|
#define MAX_INTERVAL_PRECISION 6
|
|
|
|
|
|
|
|
|
2000-06-09 03:11:16 +02:00
|
|
|
/*
|
|
|
|
* Macros for fmgr-callable functions.
|
|
|
|
*
|
2002-04-23 17:45:30 +02:00
|
|
|
* For Timestamp, we make use of the same support routines as for int64
|
|
|
|
* or float8. Therefore Timestamp is pass-by-reference if and only if
|
|
|
|
* int64 or float8 is!
|
2000-06-09 03:11:16 +02:00
|
|
|
*/
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
2002-04-23 17:45:30 +02:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
#define DatumGetTimestamp(X) ((Timestamp) DatumGetInt64(X))
|
|
|
|
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetInt64(X))
|
|
|
|
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
|
|
|
|
|
|
|
|
#define TimestampGetDatum(X) Int64GetDatum(X)
|
|
|
|
#define TimestampTzGetDatum(X) Int64GetDatum(X)
|
|
|
|
#define IntervalPGetDatum(X) PointerGetDatum(X)
|
|
|
|
|
|
|
|
#define PG_GETARG_TIMESTAMP(n) PG_GETARG_INT64(n)
|
|
|
|
#define PG_GETARG_TIMESTAMPTZ(n) PG_GETARG_INT64(n)
|
|
|
|
#define PG_GETARG_INTERVAL_P(n) DatumGetIntervalP(PG_GETARG_DATUM(n))
|
|
|
|
|
|
|
|
#define PG_RETURN_TIMESTAMP(x) PG_RETURN_INT64(x)
|
|
|
|
#define PG_RETURN_TIMESTAMPTZ(x) PG_RETURN_INT64(x)
|
|
|
|
#define PG_RETURN_INTERVAL_P(x) return IntervalPGetDatum(x)
|
|
|
|
|
|
|
|
#define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1)
|
|
|
|
#define DT_NOEND (INT64CONST(0x7fffffffffffffff))
|
|
|
|
|
|
|
|
#else
|
2002-04-23 17:45:30 +02:00
|
|
|
|
2000-06-09 03:11:16 +02:00
|
|
|
#define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X))
|
2001-10-25 07:50:21 +02:00
|
|
|
#define DatumGetTimestampTz(X) ((TimestampTz) DatumGetFloat8(X))
|
2000-06-09 03:11:16 +02:00
|
|
|
#define DatumGetIntervalP(X) ((Interval *) DatumGetPointer(X))
|
|
|
|
|
2001-09-28 10:09:14 +02:00
|
|
|
#define TimestampGetDatum(X) Float8GetDatum(X)
|
|
|
|
#define TimestampTzGetDatum(X) Float8GetDatum(X)
|
|
|
|
#define IntervalPGetDatum(X) PointerGetDatum(X)
|
2000-06-09 03:11:16 +02:00
|
|
|
|
2001-09-28 10:09:14 +02:00
|
|
|
#define PG_GETARG_TIMESTAMP(n) DatumGetTimestamp(PG_GETARG_DATUM(n))
|
|
|
|
#define PG_GETARG_TIMESTAMPTZ(n) DatumGetTimestampTz(PG_GETARG_DATUM(n))
|
2000-06-09 03:11:16 +02:00
|
|
|
#define PG_GETARG_INTERVAL_P(n) DatumGetIntervalP(PG_GETARG_DATUM(n))
|
|
|
|
|
2001-09-28 10:09:14 +02:00
|
|
|
#define PG_RETURN_TIMESTAMP(x) return TimestampGetDatum(x)
|
|
|
|
#define PG_RETURN_TIMESTAMPTZ(x) return TimestampTzGetDatum(x)
|
2000-06-09 03:11:16 +02:00
|
|
|
#define PG_RETURN_INTERVAL_P(x) return IntervalPGetDatum(x)
|
|
|
|
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
#ifdef HUGE_VAL
|
|
|
|
#define DT_NOBEGIN (-HUGE_VAL)
|
|
|
|
#define DT_NOEND (HUGE_VAL)
|
|
|
|
#else
|
|
|
|
#define DT_NOBEGIN (-DBL_MAX)
|
|
|
|
#define DT_NOEND (DBL_MAX)
|
|
|
|
#endif
|
2002-09-04 22:31:48 +02:00
|
|
|
#endif /* HAVE_INT64_TIMESTAMP */
|
2002-04-23 17:45:30 +02:00
|
|
|
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2001-03-14 21:12:10 +01:00
|
|
|
#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0)
|
|
|
|
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0)
|
2001-03-14 21:12:10 +01:00
|
|
|
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2001-09-28 10:09:14 +02:00
|
|
|
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
#ifdef HAVE_INT64_TIMESTAMP
|
2002-04-23 17:45:30 +02:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
typedef int32 fsec_t;
|
|
|
|
|
|
|
|
#else
|
2002-04-23 17:45:30 +02:00
|
|
|
|
2002-04-21 21:52:18 +02:00
|
|
|
typedef double fsec_t;
|
|
|
|
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
#define TIME_PREC_INV 1000000.0
|
|
|
|
#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV)
|
2002-04-21 21:52:18 +02:00
|
|
|
#endif
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2002-08-04 08:42:18 +02:00
|
|
|
#define TIMESTAMP_MASK(b) (1 << (b))
|
|
|
|
#define INTERVAL_MASK(b) (1 << (b))
|
|
|
|
|
|
|
|
/* Macros to handle packing and unpacking the typmod field for intervals */
|
|
|
|
#define INTERVAL_FULL_RANGE (0x7FFF)
|
|
|
|
#define INTERVAL_RANGE_MASK (0x7FFF)
|
|
|
|
#define INTERVAL_FULL_PRECISION (0xFFFF)
|
|
|
|
#define INTERVAL_PRECISION_MASK (0xFFFF)
|
|
|
|
#define INTERVAL_TYPMOD(p,r) ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK))
|
|
|
|
#define INTERVAL_PRECISION(t) ((t) & INTERVAL_PRECISION_MASK)
|
|
|
|
#define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK)
|
|
|
|
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* timestamp.c prototypes
|
|
|
|
*/
|
|
|
|
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum timestamp_in(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_out(PG_FUNCTION_ARGS);
|
2003-05-13 01:08:52 +02:00
|
|
|
extern Datum timestamp_recv(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_send(PG_FUNCTION_ARGS);
|
2001-10-03 07:29:27 +02:00
|
|
|
extern Datum timestamp_scale(PG_FUNCTION_ARGS);
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum timestamp_eq(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_ne(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_lt(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_le(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_ge(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_gt(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_finite(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_cmp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_smaller(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_larger(PG_FUNCTION_ARGS);
|
|
|
|
|
2004-03-22 02:38:18 +01:00
|
|
|
extern Datum timestamp_eq_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_ne_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_lt_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_le_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_gt_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_ge_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_cmp_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
|
|
|
|
extern Datum timestamptz_eq_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_ne_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_lt_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_le_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_gt_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_ge_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_cmp_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum interval_in(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_out(PG_FUNCTION_ARGS);
|
2003-05-13 01:08:52 +02:00
|
|
|
extern Datum interval_recv(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_send(PG_FUNCTION_ARGS);
|
2001-10-18 19:30:21 +02:00
|
|
|
extern Datum interval_scale(PG_FUNCTION_ARGS);
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum interval_eq(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_ne(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_lt(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_le(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_ge(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_gt(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_finite(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_cmp(PG_FUNCTION_ARGS);
|
2000-06-19 05:55:01 +02:00
|
|
|
extern Datum interval_hash(PG_FUNCTION_ARGS);
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum interval_smaller(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_larger(PG_FUNCTION_ARGS);
|
|
|
|
|
|
|
|
extern Datum timestamp_text(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum text_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_text(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum text_interval(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_trunc(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_trunc(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_part(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_part(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_zone(PG_FUNCTION_ARGS);
|
2000-11-06 17:05:25 +01:00
|
|
|
extern Datum timestamp_izone(PG_FUNCTION_ARGS);
|
2001-09-28 10:09:14 +02:00
|
|
|
extern Datum timestamp_timestamptz(PG_FUNCTION_ARGS);
|
|
|
|
|
|
|
|
extern Datum timestamptz_in(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_out(PG_FUNCTION_ARGS);
|
2003-05-13 01:08:52 +02:00
|
|
|
extern Datum timestamptz_recv(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_send(PG_FUNCTION_ARGS);
|
2001-10-03 07:29:27 +02:00
|
|
|
extern Datum timestamptz_scale(PG_FUNCTION_ARGS);
|
2001-09-28 10:09:14 +02:00
|
|
|
extern Datum timestamptz_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_zone(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_izone(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_timestamptz(PG_FUNCTION_ARGS);
|
2000-06-09 03:11:16 +02:00
|
|
|
|
|
|
|
extern Datum interval_um(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_pl(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_mi(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_mul(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum mul_d_interval(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_div(PG_FUNCTION_ARGS);
|
2000-07-17 05:05:41 +02:00
|
|
|
extern Datum interval_accum(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum interval_avg(PG_FUNCTION_ARGS);
|
2000-06-09 03:11:16 +02:00
|
|
|
|
|
|
|
extern Datum timestamp_mi(PG_FUNCTION_ARGS);
|
2004-02-14 21:16:18 +01:00
|
|
|
extern Datum timestamp_pl_interval(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamp_mi_interval(PG_FUNCTION_ARGS);
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum timestamp_age(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum overlaps_timestamp(PG_FUNCTION_ARGS);
|
|
|
|
|
2001-09-28 10:09:14 +02:00
|
|
|
extern Datum timestamptz_text(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum text_timestamptz(PG_FUNCTION_ARGS);
|
2004-02-14 21:16:18 +01:00
|
|
|
extern Datum timestamptz_pl_interval(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_mi_interval(PG_FUNCTION_ARGS);
|
2001-09-28 10:09:14 +02:00
|
|
|
extern Datum timestamptz_age(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_trunc(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum timestamptz_part(PG_FUNCTION_ARGS);
|
|
|
|
|
2000-06-09 03:11:16 +02:00
|
|
|
extern Datum now(PG_FUNCTION_ARGS);
|
|
|
|
|
|
|
|
/* Internal routines (not fmgr-callable) */
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2004-05-21 07:08:06 +02:00
|
|
|
extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
|
|
|
|
extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm,
|
2002-04-21 21:52:18 +02:00
|
|
|
fsec_t *fsec, char **tzn);
|
|
|
|
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2004-05-21 07:08:06 +02:00
|
|
|
extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec);
|
|
|
|
extern int tm2interval(struct pg_tm * tm, fsec_t fsec, Interval *span);
|
2001-09-06 05:22:42 +02:00
|
|
|
|
2001-09-28 10:09:14 +02:00
|
|
|
extern Timestamp SetEpochTimestamp(void);
|
2004-05-21 07:08:06 +02:00
|
|
|
extern void GetEpochTime(struct pg_tm * tm);
|
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:26:26 +01:00
|
|
|
|
2004-02-14 21:16:18 +01:00
|
|
|
extern int timestamp_cmp_internal(Timestamp dt1, Timestamp dt2);
|
|
|
|
/* timestamp comparison works for timestamptz also */
|
|
|
|
#define timestamptz_cmp_internal(dt1,dt2) timestamp_cmp_internal(dt1, dt2)
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
extern void isoweek2date(int woy, int *year, int *mon, int *mday);
|
2000-08-29 06:41:48 +02:00
|
|
|
extern int date2isoweek(int year, int mon, int mday);
|
2003-12-25 04:36:24 +01:00
|
|
|
extern int date2isoyear(int year, int mon, int mday);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* TIMESTAMP_H */
|