1 /*-------------------------------------------------------------------------
4 * Definitions for the "new" abstime code.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: nabstime.h,v 1.11 1997/09/07 05:02:46 momjian Exp $
11 *-------------------------------------------------------------------------
20 /* ----------------------------------------------------------------
21 * time types + support macros
24 * ----------------------------------------------------------------
26 typedef int32 AbsoluteTime;
27 typedef int32 RelativeTime;
34 typedef TimeIntervalData *TimeInterval;
38 * Epoch is Unix system time zero, but needs to be kept as a reserved
39 * value rather than converting to time since timezone calculations
40 * might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20
42 * Pre-v6.1 code had large decimal numbers for reserved values.
43 * These were chosen as special 32-bit bit patterns,
44 * so redefine them explicitly using these bit patterns. - tgl 97/02/24
46 #define EPOCH_ABSTIME ((AbsoluteTime) 0)
47 #define INVALID_ABSTIME ((AbsoluteTime) 0x7FFFFFFE) /* 2147483647 == 2^31 -
49 #define CURRENT_ABSTIME ((AbsoluteTime) 0x7FFFFFFD) /* 2147483646 == 2^31 -
51 #define NOEND_ABSTIME ((AbsoluteTime) 0x7FFFFFFC) /* 2147483645 == 2^31 -
53 #define BIG_ABSTIME ((AbsoluteTime) 0x7FFFFFFB) /* 2147483644 == 2^31 -
58 * AIX considers 2147483648 == -2147483648 (since they have the same bit
59 * representation) but uses a different sign sense in a comparison to
60 * these integer constants depending on whether the constant is signed
63 #define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN)
65 #define NOSTART_ABSTIME ((AbsoluteTime) 0x80000001) /* -2147483647 == - 2^31 */
68 #define INVALID_RELTIME ((RelativeTime) 0x7FFFFFFE) /* 2147483647 == 2^31 -
71 #define AbsoluteTimeIsValid(time) \
72 ((bool) ((time) != INVALID_ABSTIME))
74 #define AbsoluteTimeIsReal(time) \
75 ((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
76 ((AbsoluteTime) time) > NOSTART_ABSTIME))
78 /* have to include this because EPOCH_ABSTIME used to be invalid - yuk */
79 #define AbsoluteTimeIsBackwardCompatiblyValid(time) \
80 ((bool) (((AbsoluteTime) time) != INVALID_ABSTIME && \
81 ((AbsoluteTime) time) > EPOCH_ABSTIME))
83 #define AbsoluteTimeIsBackwardCompatiblyReal(time) \
84 ((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
85 ((AbsoluteTime) time) > NOSTART_ABSTIME && \
86 ((AbsoluteTime) time) > EPOCH_ABSTIME))
88 #define RelativeTimeIsValid(time) \
89 ((bool) (((RelativeTime) time) != INVALID_RELTIME))
91 extern AbsoluteTime GetCurrentAbsoluteTime(void);
95 * Returns system time.
97 #define getSystemTime() \
102 * nabstime.c prototypes
104 extern AbsoluteTime nabstimein(char *timestr);
105 extern char *nabstimeout(AbsoluteTime time);
107 extern bool abstimeeq(AbsoluteTime t1, AbsoluteTime t2);
108 extern bool abstimene(AbsoluteTime t1, AbsoluteTime t2);
109 extern bool abstimelt(AbsoluteTime t1, AbsoluteTime t2);
110 extern bool abstimegt(AbsoluteTime t1, AbsoluteTime t2);
111 extern bool abstimele(AbsoluteTime t1, AbsoluteTime t2);
112 extern bool abstimege(AbsoluteTime t1, AbsoluteTime t2);
113 extern bool abstime_finite(AbsoluteTime time);
115 extern AbsoluteTime datetime_abstime(DateTime * datetime);
116 extern DateTime *abstime_datetime(AbsoluteTime abstime);
118 extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2);
119 extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2);
121 extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn);
123 #endif /* NABSTIME_H */