aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/timestamp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/utils/timestamp.h')
-rw-r--r--src/include/utils/timestamp.h42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index cea772afb77..bce73ae0801 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: timestamp.h,v 1.3 2000/04/07 13:40:12 thomas Exp $
+ * $Id: timestamp.h,v 1.4 2000/04/12 17:16:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,8 +31,10 @@ typedef double Timestamp;
typedef struct
{
- double time; /* all time units other than months and years */
- int4 month; /* months and years, after time for alignment */
+ double time; /* all time units other than months and
+ * years */
+ int4 month; /* months and years, after time for
+ * alignment */
} Interval;
@@ -51,29 +53,29 @@ typedef struct
#define DT_CURRENT (DBL_MIN)
#define DT_EPOCH (-DBL_MIN)
-#define TIMESTAMP_INVALID(j) {j = DT_INVALID;}
+#define TIMESTAMP_INVALID(j) do {j = DT_INVALID;} while (0)
#ifdef NAN
-#define TIMESTAMP_IS_INVALID(j) (isnan(j))
+#define TIMESTAMP_IS_INVALID(j) (isnan(j))
#else
-#define TIMESTAMP_IS_INVALID(j) (j == DT_INVALID)
+#define TIMESTAMP_IS_INVALID(j) (j == DT_INVALID)
#endif
-#define TIMESTAMP_NOBEGIN(j) {j = DT_NOBEGIN;}
-#define TIMESTAMP_IS_NOBEGIN(j) (j == DT_NOBEGIN)
+#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0)
+#define TIMESTAMP_IS_NOBEGIN(j) (j == DT_NOBEGIN)
-#define TIMESTAMP_NOEND(j) {j = DT_NOEND;}
+#define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0)
#define TIMESTAMP_IS_NOEND(j) (j == DT_NOEND)
-#define TIMESTAMP_CURRENT(j) {j = DT_CURRENT;}
+#define TIMESTAMP_CURRENT(j) do {j = DT_CURRENT;} while (0)
#if defined(linux) && defined(__powerpc__)
extern int timestamp_is_current(double j);
-#define TIMESTAMP_IS_CURRENT(j) timestamp_is_current(j)
+#define TIMESTAMP_IS_CURRENT(j) timestamp_is_current(j)
#else
-#define TIMESTAMP_IS_CURRENT(j) (j == DT_CURRENT)
+#define TIMESTAMP_IS_CURRENT(j) (j == DT_CURRENT)
#endif
-#define TIMESTAMP_EPOCH(j) {j = DT_EPOCH;}
+#define TIMESTAMP_EPOCH(j) do {j = DT_EPOCH;} while (0)
#if defined(linux) && defined(__powerpc__)
extern int timestamp_is_epoch(double j);
@@ -83,11 +85,11 @@ extern int timestamp_is_epoch(double j);
#endif
#define TIMESTAMP_IS_RELATIVE(j) (TIMESTAMP_IS_CURRENT(j) || TIMESTAMP_IS_EPOCH(j))
-#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_INVALID(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 INTERVAL_INVALID(j) {(j).time = DT_INVALID;}
+#define INTERVAL_INVALID(j) do {(j).time = DT_INVALID;} while (0)
#ifdef NAN
#define INTERVAL_IS_INVALID(j) (isnan((j).time))
#else
@@ -152,15 +154,15 @@ extern Timestamp *timestamp_mi_span(Timestamp *dt, Interval *span);
extern Interval *timestamp_age(Timestamp *dt1, Timestamp *dt2);
extern bool overlaps_timestamp(Timestamp *dt1, Timestamp *dt2, Timestamp *dt3, Timestamp *dt4);
-extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
-extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn);
+extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
+extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, double *fsec, char **tzn);
extern Timestamp SetTimestamp(Timestamp timestamp);
extern Timestamp dt2local(Timestamp dt, int timezone);
extern void dt2time(Timestamp dt, int *hour, int *min, double *sec);
-extern int EncodeSpecialTimestamp(Timestamp dt, char *str);
-extern int interval2tm(Interval span, struct tm * tm, float8 *fsec);
-extern int tm2interval(struct tm * tm, double fsec, Interval *span);
+extern int EncodeSpecialTimestamp(Timestamp dt, char *str);
+extern int interval2tm(Interval span, struct tm * tm, float8 *fsec);
+extern int tm2interval(struct tm * tm, double fsec, Interval *span);
extern Timestamp *now(void);
#endif /* TIMESTAMP_H */