1996-11-10 04:06:38 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* datetime.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
|
|
|
* Definitions for the date/time and other date/time support code.
|
|
|
|
* The support code is shared with other date data types,
|
|
|
|
* including abstime, reltime, date, and time.
|
1996-11-10 04:06:38 +01:00
|
|
|
*
|
|
|
|
*
|
2001-01-24 20:43:33 +01:00
|
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-11-10 04:06:38 +01:00
|
|
|
*
|
2002-04-21 21:52:18 +02:00
|
|
|
* $Id: datetime.h,v 1.29 2002/04/21 19:48:31 thomas Exp $
|
1996-11-10 04:06:38 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef DATETIME_H
|
|
|
|
#define DATETIME_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
|
|
|
#include <time.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <limits.h>
|
2001-07-10 03:39:20 +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
|
|
|
#include "utils/timestamp.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
|
|
|
* time types + support macros
|
|
|
|
*
|
|
|
|
* String definitions for standard time quantities.
|
|
|
|
*
|
|
|
|
* These strings are the defaults used to form output time strings.
|
|
|
|
* Other alternate forms are hardcoded into token tables in datetime.c.
|
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DAGO "ago"
|
|
|
|
#define DCURRENT "current"
|
|
|
|
#define EPOCH "epoch"
|
|
|
|
#define INVALID "invalid"
|
|
|
|
#define EARLY "-infinity"
|
|
|
|
#define LATE "infinity"
|
|
|
|
#define NOW "now"
|
|
|
|
#define TODAY "today"
|
|
|
|
#define TOMORROW "tomorrow"
|
|
|
|
#define YESTERDAY "yesterday"
|
|
|
|
#define ZULU "zulu"
|
|
|
|
|
|
|
|
#define DMICROSEC "usecond"
|
|
|
|
#define DMILLISEC "msecond"
|
|
|
|
#define DSECOND "second"
|
|
|
|
#define DMINUTE "minute"
|
|
|
|
#define DHOUR "hour"
|
|
|
|
#define DDAY "day"
|
|
|
|
#define DWEEK "week"
|
|
|
|
#define DMONTH "month"
|
|
|
|
#define DQUARTER "quarter"
|
|
|
|
#define DYEAR "year"
|
|
|
|
#define DDECADE "decade"
|
|
|
|
#define DCENTURY "century"
|
2000-04-14 17:22:22 +02:00
|
|
|
#define DMILLENNIUM "millennium"
|
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 DA_D "ad"
|
|
|
|
#define DB_C "bc"
|
|
|
|
#define DTIMEZONE "timezone"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fundamental time field definitions for parsing.
|
|
|
|
*
|
|
|
|
* Meridian: am, pm, or 24-hour style.
|
2000-04-14 17:22:22 +02:00
|
|
|
* Millennium: ad, bc
|
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 AM 0
|
|
|
|
#define PM 1
|
|
|
|
#define HR24 2
|
|
|
|
|
|
|
|
#define AD 0
|
|
|
|
#define BC 1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fields for time decoding.
|
2001-10-23 22:17:27 +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
|
|
|
* Can't have more of these than there are bits in an unsigned int
|
2001-10-23 22:17:27 +02:00
|
|
|
* since these are turned into bit masks during parsing and decoding.
|
|
|
|
*
|
|
|
|
* Furthermore, the values for YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
|
|
|
|
* must be in the range 0..14 so that the associated bitmasks can fit
|
|
|
|
* into the left half of an INTERVAL's typmod value.
|
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 RESERV 0
|
|
|
|
#define MONTH 1
|
|
|
|
#define YEAR 2
|
|
|
|
#define DAY 3
|
2001-09-28 10:09:14 +02:00
|
|
|
#define JULIAN 4
|
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 TZ 5
|
|
|
|
#define DTZ 6
|
|
|
|
#define DTZMOD 7
|
|
|
|
#define IGNORE 8
|
|
|
|
#define AMPM 9
|
|
|
|
#define HOUR 10
|
|
|
|
#define MINUTE 11
|
|
|
|
#define SECOND 12
|
|
|
|
#define DOY 13
|
|
|
|
#define DOW 14
|
|
|
|
#define UNITS 15
|
|
|
|
#define ADBC 16
|
|
|
|
/* these are only for relative dates */
|
|
|
|
#define AGO 17
|
|
|
|
#define ABS_BEFORE 18
|
|
|
|
#define ABS_AFTER 19
|
2001-12-29 19:31:48 +01:00
|
|
|
/* generic fields to help with parsing */
|
2002-01-01 03:54:33 +01:00
|
|
|
#define ISODATE 20
|
|
|
|
#define ISOTIME 21
|
2001-09-28 10:09:14 +02:00
|
|
|
/* reserved for unrecognized string values */
|
|
|
|
#define UNKNOWN_FIELD 31
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Token field definitions for time parsing and decoding.
|
|
|
|
* These need to fit into the datetkn table type.
|
|
|
|
* At the moment, that means keep them within [-127,127].
|
|
|
|
* These are also used for bit masks in DecodeDateDelta()
|
|
|
|
* so actually restrict them to within [0,31] for now.
|
|
|
|
* - thomas 97/06/19
|
|
|
|
* Not all of these fields are used for masks in DecodeDateDelta
|
|
|
|
* so allow some larger than 31. - thomas 1997-11-17
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DTK_NUMBER 0
|
|
|
|
#define DTK_STRING 1
|
|
|
|
|
|
|
|
#define DTK_DATE 2
|
|
|
|
#define DTK_TIME 3
|
|
|
|
#define DTK_TZ 4
|
|
|
|
#define DTK_AGO 5
|
|
|
|
|
|
|
|
#define DTK_SPECIAL 6
|
|
|
|
#define DTK_INVALID 7
|
|
|
|
#define DTK_CURRENT 8
|
|
|
|
#define DTK_EARLY 9
|
|
|
|
#define DTK_LATE 10
|
|
|
|
#define DTK_EPOCH 11
|
|
|
|
#define DTK_NOW 12
|
|
|
|
#define DTK_YESTERDAY 13
|
|
|
|
#define DTK_TODAY 14
|
|
|
|
#define DTK_TOMORROW 15
|
|
|
|
#define DTK_ZULU 16
|
|
|
|
|
|
|
|
#define DTK_DELTA 17
|
|
|
|
#define DTK_SECOND 18
|
|
|
|
#define DTK_MINUTE 19
|
|
|
|
#define DTK_HOUR 20
|
|
|
|
#define DTK_DAY 21
|
|
|
|
#define DTK_WEEK 22
|
|
|
|
#define DTK_MONTH 23
|
|
|
|
#define DTK_QUARTER 24
|
|
|
|
#define DTK_YEAR 25
|
|
|
|
#define DTK_DECADE 26
|
|
|
|
#define DTK_CENTURY 27
|
2000-04-14 17:22:22 +02:00
|
|
|
#define DTK_MILLENNIUM 28
|
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 DTK_MILLISEC 29
|
|
|
|
#define DTK_MICROSEC 30
|
2001-09-28 10:09:14 +02:00
|
|
|
#define DTK_JULIAN 31
|
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 DTK_DOW 32
|
|
|
|
#define DTK_DOY 33
|
|
|
|
#define DTK_TZ_HOUR 34
|
|
|
|
#define DTK_TZ_MINUTE 35
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Bit mask definitions for time parsing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DTK_M(t) (0x01 << (t))
|
|
|
|
|
|
|
|
#define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
|
|
|
|
#define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND))
|
|
|
|
|
2000-05-29 21:16:57 +02:00
|
|
|
#define MAXDATELEN 51 /* maximum possible length of an input
|
|
|
|
* date string (not counting tr. null) */
|
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 MAXDATEFIELDS 25 /* maximum possible number of fields in a
|
|
|
|
* date string */
|
|
|
|
#define TOKMAXLEN 10 /* only this many chars are stored in
|
|
|
|
* datetktbl */
|
|
|
|
|
|
|
|
/* keep this struct small; it gets used a lot */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
#if defined(_AIX)
|
|
|
|
char *token;
|
|
|
|
#else
|
|
|
|
char token[TOKMAXLEN];
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* _AIX */
|
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
|
|
|
char type;
|
|
|
|
char value; /* this may be unsigned, alas */
|
|
|
|
} datetkn;
|
|
|
|
|
|
|
|
|
|
|
|
/* TMODULO()
|
|
|
|
* Macro to replace modf(), which is broken on some platforms.
|
2002-04-21 21:52:18 +02:00
|
|
|
* t = input and remainder
|
|
|
|
* q = integer part
|
|
|
|
* u = divisor
|
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
|
|
|
|
#define TMODULO(t,q,u) \
|
|
|
|
do { \
|
|
|
|
q = (t / u); \
|
|
|
|
if (q != 0) t -= (q * u); \
|
|
|
|
} while(0)
|
|
|
|
#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
|
|
|
#define TMODULO(t,q,u) \
|
|
|
|
do { \
|
|
|
|
q = ((t < 0)? ceil(t / u): floor(t / u)); \
|
2002-04-21 21:52:18 +02:00
|
|
|
if (q != 0) t -= rint(q * u); \
|
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
|
|
|
} while(0)
|
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-04-21 21:52:18 +02:00
|
|
|
/* Global variable holding time zone information. */
|
|
|
|
#if defined(__CYGWIN__) || defined(N_PLAT_NLM)
|
2001-01-18 08:22:43 +01:00
|
|
|
#define TIMEZONE_GLOBAL _timezone
|
|
|
|
#else
|
|
|
|
#define TIMEZONE_GLOBAL timezone
|
|
|
|
#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
|
|
|
|
|
|
|
/*
|
|
|
|
* Date/time validation
|
|
|
|
* Include check for leap year.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int day_tab[2][13];
|
|
|
|
|
|
|
|
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
|
|
|
|
|
|
|
/* Julian date support for date2j() and j2date()
|
|
|
|
* Set the minimum year to one greater than the year of the first valid day
|
|
|
|
* to avoid having to check year and day both. - tgl 97/05/08
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define JULIAN_MINYEAR (-4713)
|
|
|
|
#define JULIAN_MINMONTH (11)
|
|
|
|
#define JULIAN_MINDAY (23)
|
|
|
|
|
2001-07-10 03:39:20 +02:00
|
|
|
#define IS_VALID_JULIAN(y,m,d) (((y) > JULIAN_MINYEAR) \
|
|
|
|
|| (((y) == JULIAN_MINYEAR) && (((m) > JULIAN_MINMONTH) \
|
|
|
|
|| (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY)))))
|
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 UTIME_MINYEAR (1901)
|
|
|
|
#define UTIME_MINMONTH (12)
|
|
|
|
#define UTIME_MINDAY (14)
|
|
|
|
#define UTIME_MAXYEAR (2038)
|
|
|
|
#define UTIME_MAXMONTH (01)
|
|
|
|
#define UTIME_MAXDAY (18)
|
|
|
|
|
2001-07-10 03:39:20 +02:00
|
|
|
#define IS_VALID_UTIME(y,m,d) ((((y) > UTIME_MINYEAR) \
|
|
|
|
|| (((y) == UTIME_MINYEAR) && (((m) > UTIME_MINMONTH) \
|
|
|
|
|| (((m) == UTIME_MINMONTH) && ((d) >= UTIME_MINDAY))))) \
|
|
|
|
&& (((y) < UTIME_MAXYEAR) \
|
|
|
|
|| (((y) == UTIME_MAXYEAR) && (((m) < UTIME_MAXMONTH) \
|
|
|
|
|| (((m) == UTIME_MAXMONTH) && ((d) <= UTIME_MAXDAY))))))
|
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
|
|
|
|
|
|
|
|
|
|
|
extern void GetCurrentTime(struct tm * tm);
|
2002-04-21 21:52:18 +02:00
|
|
|
extern void GetCurrentTimeUsec(struct tm * tm, 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
|
|
|
extern void j2date(int jd, int *year, int *month, int *day);
|
|
|
|
extern int date2j(int year, int month, int day);
|
|
|
|
|
|
|
|
extern int ParseDateTime(char *timestr, char *lowstr,
|
2000-04-12 19:17:23 +02:00
|
|
|
char **field, int *ftype,
|
|
|
|
int maxfields, int *numfields);
|
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
|
|
|
extern int DecodeDateTime(char **field, int *ftype,
|
2000-04-12 19:17:23 +02:00
|
|
|
int nf, int *dtype,
|
2002-04-21 21:52:18 +02:00
|
|
|
struct tm * tm, fsec_t *fsec, int *tzp);
|
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-03-15 00:06:59 +01:00
|
|
|
extern int DecodeTimeOnly(char **field, int *ftype,
|
2000-04-12 19:17:23 +02:00
|
|
|
int nf, int *dtype,
|
2002-04-21 21:52:18 +02:00
|
|
|
struct tm * tm, fsec_t *fsec, int *tzp);
|
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
|
|
|
extern int DecodeInterval(char **field, int *ftype,
|
2000-04-12 19:17:23 +02:00
|
|
|
int nf, int *dtype,
|
2002-04-21 21:52:18 +02:00
|
|
|
struct tm * tm, 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
|
|
|
|
2001-05-04 00:53:07 +02:00
|
|
|
extern int DetermineLocalTimeZone(struct tm * tm);
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
extern int EncodeDateOnly(struct tm * tm, int style, char *str);
|
2002-04-21 21:52:18 +02:00
|
|
|
extern int EncodeTimeOnly(struct tm * tm, fsec_t fsec, int *tzp, int style, char *str);
|
|
|
|
extern int EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str);
|
|
|
|
extern int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
|
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
|
|
|
extern int DecodeSpecial(int field, char *lowtoken, int *val);
|
|
|
|
extern int DecodeUnits(int field, char *lowtoken, int *val);
|
2001-06-18 18:14:44 +02:00
|
|
|
extern void ClearDateCache(bool);
|
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
|
|
|
extern int j2day(int jd);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* DATETIME_H */
|