summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas G. Lockhart1999-03-03 05:11:39 +0000
committerThomas G. Lockhart1999-03-03 05:11:39 +0000
commit5e73ab70e6316fb7e3207e545aa951d847d20967 (patch)
treec7303ee89fc144ba26585f4b15bdce240bc4c69a
parentc569f2a068a7e102c7a1bf5f32cbf2151cbf26ef (diff)
Move common date/time macros to a central place.
-rw-r--r--src/include/utils/dt.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/include/utils/dt.h b/src/include/utils/dt.h
index 5b93abac76f..5ef4f32206d 100644
--- a/src/include/utils/dt.h
+++ b/src/include/utils/dt.h
@@ -8,7 +8,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: dt.h,v 1.33 1998/10/08 18:30:50 momjian Exp $
+ * $Id: dt.h,v 1.33.2.1 1999/03/03 05:11:39 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -261,6 +261,29 @@ extern int datetime_is_epoch(double j);
#define TIME_PREC_INV 1000000.0
#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV)
+
+/*
+ * 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)
+
+#define IS_VALID_JULIAN(y,m,d) ((y > JULIAN_MINYEAR) \
+ || ((y == JULIAN_MINYEAR) && ((m > JULIAN_MINMONTH) \
+ || ((m == JULIAN_MINMONTH) && (d >= JULIAN_MINDAY)))))
+
/*
* dt.c prototypes
*/