diff options
Diffstat (limited to 'src/include/utils/datetime.h')
-rw-r--r-- | src/include/utils/datetime.h | 174 |
1 files changed, 5 insertions, 169 deletions
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index 3df9ddf19f0..e6469d46de5 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: datetime.h,v 1.10 2000/02/16 17:26:26 thomas Exp $ + * $Id: datetime.h,v 1.11 2000/03/14 23:06:50 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -21,32 +21,6 @@ #include <limits.h> #include "utils/timestamp.h" -#if 0 - - -/* - * Timestamp represents absolute time. - * TimeSpan 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, - * consisting of a beginning and ending time, not a time span - thomas 97/03/20 - */ - -typedef double Timestamp; - -typedef struct -{ - double time; /* all time units other than months and - * years */ - int4 month; /* months and years, after time for - * alignment */ -} TimeSpan; - - -#endif - /* ---------------------------------------------------------------- * time types + support macros @@ -209,74 +183,6 @@ typedef struct } datetkn; -#if 0 - - -#ifdef NAN -#define TIMESTAMP_INVALID (NAN) -#else -#define TIMESTAMP_INVALID (DBL_MIN+DBL_MIN) -#endif -#ifdef HUGE_VAL -#define TIMESTAMP_NOBEGIN (-HUGE_VAL) -#define TIMESTAMP_NOEND (HUGE_VAL) -#else -#define TIMESTAMP_NOBEGIN (-DBL_MAX) -#define TIMESTAMP_NOEND (DBL_MAX) -#endif -#define TIMESTAMP_CURRENT (DBL_MIN) -#define TIMESTAMP_EPOCH (-DBL_MIN) - -#define TIMESTAMP_INVALID(j) {j = TIMESTAMP_INVALID;} -#ifdef NAN -#define TIMESTAMP_IS_INVALID(j) (isnan(j)) -#else -#define TIMESTAMP_IS_INVALID(j) (j == TIMESTAMP_INVALID) -#endif - -#define TIMESTAMP_NOBEGIN(j) {j = DT_NOBEGIN;} -#define TIMESTAMP_IS_NOBEGIN(j) (j == TIMESTAMP_NOBEGIN) - -#define TIMESTAMP_NOEND(j) {j = TIMESTAMP_NOEND;} -#define TIMESTAMP_IS_NOEND(j) (j == TIMESTAMP_NOEND) - -#define TIMESTAMP_CURRENT(j) {j = TIMESTAMP_CURRENT;} -#if defined(linux) && defined(__powerpc__) -extern int timestamp_is_current(double j); - -#define TIMESTAMP_IS_CURRENT(j) timestamp_is_current(j) -#else -#define TIMESTAMP_IS_CURRENT(j) (j == TIMESTAMP_CURRENT) -#endif - -#define TIMESTAMP_EPOCH(j) {j = TIMESTAMP_EPOCH;} -#if defined(linux) && defined(__powerpc__) -extern int timestamp_is_epoch(double j); - -#define TIMESTAMP_IS_EPOCH(j) timestamp_is_epoch(j) -#else -#define TIMESTAMP_IS_EPOCH(j) (j == TIMESTAMP_EPOCH) -#endif - -#define TIMESTAMP_IS_RELATIVE(j) (TIMESTAMP_IS_CURRENT(j) || TIMESTAMP_IS_EPOCH(j)) -#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_INVALID(j) \ - || TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j)) -#define TIMESTAMP_IS_RESERVED(j) (TIMESTAMP_IS_RELATIVE(j) || TIMESTAMP_NOT_FINITE(j)) - -#define TIMESPAN_INVALID(j) {(j).time = DT_INVALID;} -#ifdef NAN -#define TIMESPAN_IS_INVALID(j) (isnan((j).time)) -#else -#define TIMESPAN_IS_INVALID(j) ((j).time == DATETIME_INVALID) -#endif -#define TIMESPAN_NOT_FINITE(j) TIMESPAN_IS_INVALID(j) - -#define TIME_PREC_INV 1000000.0 -#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV) - - -#endif - /* TMODULO() * Macro to replace modf(), which is broken on some platforms. */ @@ -325,63 +231,6 @@ extern int day_tab[2][13]; || ((m == UTIME_MAXMONTH) && (d <= UTIME_MAXDAY)))))) -#if 0 - - -/* - * datetime.c prototypes - */ - -extern DateTime *datetime_in(char *str); -extern char *datetime_out(DateTime *dt); -extern bool datetime_eq(DateTime *dt1, DateTime *dt2); -extern bool datetime_ne(DateTime *dt1, DateTime *dt2); -extern bool datetime_lt(DateTime *dt1, DateTime *dt2); -extern bool datetime_le(DateTime *dt1, DateTime *dt2); -extern bool datetime_ge(DateTime *dt1, DateTime *dt2); -extern bool datetime_gt(DateTime *dt1, DateTime *dt2); -extern bool datetime_finite(DateTime *datetime); -extern int datetime_cmp(DateTime *dt1, DateTime *dt2); -extern DateTime *datetime_smaller(DateTime *dt1, DateTime *dt2); -extern DateTime *datetime_larger(DateTime *dt1, DateTime *dt2); - -extern TimeSpan *timespan_in(char *str); -extern char *timespan_out(TimeSpan *span); -extern bool timespan_eq(TimeSpan *span1, TimeSpan *span2); -extern bool timespan_ne(TimeSpan *span1, TimeSpan *span2); -extern bool timespan_lt(TimeSpan *span1, TimeSpan *span2); -extern bool timespan_le(TimeSpan *span1, TimeSpan *span2); -extern bool timespan_ge(TimeSpan *span1, TimeSpan *span2); -extern bool timespan_gt(TimeSpan *span1, TimeSpan *span2); -extern bool timespan_finite(TimeSpan *span); -extern int timespan_cmp(TimeSpan *span1, TimeSpan *span2); -extern TimeSpan *timespan_smaller(TimeSpan *span1, TimeSpan *span2); -extern TimeSpan *timespan_larger(TimeSpan *span1, TimeSpan *span2); - -extern text *datetime_text(DateTime *datetime); -extern DateTime *text_datetime(text *str); -extern text *timespan_text(TimeSpan *timespan); -extern TimeSpan *text_timespan(text *str); -extern DateTime *datetime_trunc(text *units, DateTime *datetime); -extern TimeSpan *timespan_trunc(text *units, TimeSpan *timespan); -extern float64 datetime_part(text *units, DateTime *datetime); -extern float64 timespan_part(text *units, TimeSpan *timespan); -extern text *datetime_zone(text *zone, DateTime *datetime); - -extern TimeSpan *timespan_um(TimeSpan *span); -extern TimeSpan *timespan_pl(TimeSpan *span1, TimeSpan *span2); -extern TimeSpan *timespan_mi(TimeSpan *span1, TimeSpan *span2); -extern TimeSpan *timespan_div(TimeSpan *span1, float8 *arg2); - -extern TimeSpan *datetime_mi(DateTime *dt1, DateTime *dt2); -extern DateTime *datetime_pl_span(DateTime *dt, TimeSpan *span); -extern DateTime *datetime_mi_span(DateTime *dt, TimeSpan *span); -extern TimeSpan *datetime_age(DateTime *dt1, DateTime *dt2); - - -#endif - - extern void GetCurrentTime(struct tm * tm); extern void j2date(int jd, int *year, int *month, int *day); extern int date2j(int year, int month, int day); @@ -393,15 +242,16 @@ extern int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct tm * tm, double *fsec, int *tzp); -extern int DecodeTimeOnly(char **field, int *ftype, int nf, - int *dtype, struct tm * tm, double *fsec); +extern int DecodeTimeOnly(char **field, int *ftype, + int nf, int *dtype, + struct tm * tm, double *fsec, int *tzp); extern int DecodeDateDelta(char **field, int *ftype, int nf, int *dtype, struct tm * tm, double *fsec); extern int EncodeDateOnly(struct tm * tm, int style, char *str); -extern int EncodeTimeOnly(struct tm * tm, double fsec, int style, char *str); +extern int EncodeTimeOnly(struct tm * tm, double fsec, int *tzp, int style, char *str); extern int EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str); extern int EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str); @@ -421,18 +271,4 @@ extern datetkn *datebsearch(char *key, datetkn *base, unsigned int nel); extern int j2day(int jd); - -#if 0 - - -static int EncodeSpecialTimestamp(Timestamp dt, char *str); -static Timestamp dt2local(Timestamp dt, int timezone); -static void dt2time(Timestamp dt, int *hour, int *min, double *sec); -static int timespan2tm(TimeSpan span, struct tm * tm, float8 *fsec); -static int tm2timespan(struct tm * tm, double fsec, TimeSpan *span); - - -#endif - - #endif /* DATETIME_H */ |