diff options
Diffstat (limited to 'src/include/utils/nabstime.h')
| -rw-r--r-- | src/include/utils/nabstime.h | 103 |
1 files changed, 37 insertions, 66 deletions
diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index d5d34c8b9c..8a0c92b257 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nabstime.h,v 1.4 1996/11/04 07:18:45 scrappy Exp $ + * $Id: nabstime.h,v 1.5 1997/03/14 23:33:29 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -14,6 +14,8 @@ #define NABSTIME_H #include <time.h> +#include "utils/dt.h" + /* ---------------------------------------------------------------- * time types + support macros @@ -30,11 +32,21 @@ typedef struct { } TimeIntervalData; typedef TimeIntervalData *TimeInterval; +/* + * Reserved values + * Epoch is Unix system time zero, but needs to be kept as a reserved + * value rather than converting to time since timezone calculations + * might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20 + * + * Pre-v6.1 code had large decimal numbers for reserved values. + * These were chosen as special 32-bit bit patterns, + * so redefine them explicitly using these bit patterns. - tgl 97/02/24 + */ #define EPOCH_ABSTIME ((AbsoluteTime) 0) -#define INVALID_ABSTIME ((AbsoluteTime) 2147483647) /* 2^31 - 1 */ -#define CURRENT_ABSTIME ((AbsoluteTime) 2147483646) /* 2^31 - 2 */ -#define NOEND_ABSTIME ((AbsoluteTime) 2147483645) /* 2^31 - 3 */ - +#define INVALID_ABSTIME ((AbsoluteTime) 0x4FFFFFFE) /* 2147483647 == 2^31 - 1 */ +#define CURRENT_ABSTIME ((AbsoluteTime) 0x4FFFFFFD) /* 2147483646 == 2^31 - 2 */ +#define NOEND_ABSTIME ((AbsoluteTime) 0x4FFFFFFC) /* 2147483645 == 2^31 - 3 */ +#define BIG_ABSTIME ((AbsoluteTime) 0x4FFFFFFB) /* 2147483644 == 2^31 - 4 */ #if defined(aix) /* @@ -47,15 +59,10 @@ typedef TimeIntervalData *TimeInterval; #define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN) #else /*#define NOSTART_ABSTIME ((AbsoluteTime) 2147483648)*/ /* - 2^31 */ -#define NOSTART_ABSTIME ((AbsoluteTime) -2147483647) /* - 2^31 */ +#define NOSTART_ABSTIME ((AbsoluteTime) 0x80000001) /* -2147483647 == - 2^31 */ #endif /* aix */ -#define INVALID_RELTIME ((RelativeTime) 2147483647) /* 2^31 - 1 */ - -/* ---------------- - * time support macros (from tim.h) - * ---------------- - */ +#define INVALID_RELTIME ((RelativeTime) 0x4FFFFFFE) /* 2147483647 == 2^31 - 1 */ #define AbsoluteTimeIsValid(time) \ ((bool) ((time) != INVALID_ABSTIME)) @@ -77,9 +84,17 @@ typedef TimeIntervalData *TimeInterval; #define RelativeTimeIsValid(time) \ ((bool) (((RelativeTime) time) != INVALID_RELTIME)) +#if USE_NEW_TIME_CODE + +extern AbsoluteTime GetCurrentAbsoluteTime(void); + +#else + #define GetCurrentAbsoluteTime() \ ((AbsoluteTime) getSystemTime()) +#endif + /* * getSystemTime -- * Returns system time. @@ -87,73 +102,29 @@ typedef TimeIntervalData *TimeInterval; #define getSystemTime() \ ((time_t) (time(0l))) - -/* - * Meridian: am, pm, or 24-hour style. - */ -#define AM 0 -#define PM 1 -#define HR24 2 - -/* can't have more of these than there are bits in an unsigned long */ -#define MONTH 1 -#define YEAR 2 -#define DAY 3 -#define TIME 4 -#define TZ 5 -#define DTZ 6 -#define PG_IGNORE 7 -#define AMPM 8 -/* below here are unused so far */ -#define SECONDS 9 -#define MONTHS 10 -#define YEARS 11 -#define NUMBER 12 -/* these are only for relative dates */ -#define ABS_BEFORE 13 -#define ABS_AFTER 14 -#define AGO 15 - - #define SECS(n) ((time_t)(n)) #define MINS(n) ((time_t)(n) * SECS(60)) #define HOURS(n) ((time_t)(n) * MINS(60)) /* 3600 secs */ #define DAYS(n) ((time_t)(n) * HOURS(24)) /* 86400 secs */ /* months and years are not constant length, must be specially dealt with */ -#define TOKMAXLEN 6 /* 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]; -#endif /* aix */ - char type; - char value; /* this may be unsigned, alas */ -} datetkn; /* * nabstime.c prototypes */ extern AbsoluteTime nabstimein(char *timestr); -extern int prsabsdate(char *timestr, struct tm *tm, int *tzp); -extern int tryabsdate(char *fields[], int nf, struct tm *tm, int *tzp); -extern int parsetime(char *time, struct tm *tm); -extern int split(char *string, char *fields[], int nfields, char *sep); extern char *nabstimeout(AbsoluteTime time); -extern AbsoluteTime dateconv(struct tm *tm, int zone); -extern time_t qmktime(struct tm *tp); -extern datetkn *datetoktype(char *s, int *bigvalp); -extern datetkn *datebsearch(char *key, datetkn *base, unsigned int nel); + extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2); extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2); -extern int32 abstimeeq(AbsoluteTime t1, AbsoluteTime t2); -extern int32 abstimene(AbsoluteTime t1, AbsoluteTime t2); -extern int32 abstimelt(AbsoluteTime t1, AbsoluteTime t2); -extern int32 abstimegt(AbsoluteTime t1, AbsoluteTime t2); -extern int32 abstimele(AbsoluteTime t1, AbsoluteTime t2); -extern int32 abstimege(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimeeq(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimene(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimelt(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimegt(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimele(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimege(AbsoluteTime t1, AbsoluteTime t2); + +extern AbsoluteTime dateconv(struct tm *tm, int zone); +extern time_t qmktime(struct tm *tp); #endif /* NABSTIME_H */ |
