Skip to content

Commit 5e73ab7

Browse files
author
Thomas G. Lockhart
committed
Move common date/time macros to a central place.
1 parent c569f2a commit 5e73ab7

File tree

1 file changed

+24
-1
lines changed
  • src/include/utils

1 file changed

+24
-1
lines changed

src/include/utils/dt.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: dt.h,v 1.33 1998/10/08 18:30:50 momjian Exp $
11+
* $Id: dt.h,v 1.33.2.1 1999/03/03 05:11:39 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -261,6 +261,29 @@ extern int datetime_is_epoch(double j);
261261
#define TIME_PREC_INV 1000000.0
262262
#define JROUND(j) (rint(((double) (j))*TIME_PREC_INV)/TIME_PREC_INV)
263263

264+
265+
/*
266+
* Date/time validation
267+
* Include check for leap year.
268+
*/
269+
270+
extern int day_tab[2][13];
271+
272+
#define isleap(y) (((y % 4) == 0 && (y % 100) != 0) || (y % 400) == 0)
273+
274+
/* Julian date support for date2j() and j2date()
275+
* Set the minimum year to one greater than the year of the first valid day
276+
* to avoid having to check year and day both. - tgl 97/05/08
277+
*/
278+
279+
#define JULIAN_MINYEAR (-4713)
280+
#define JULIAN_MINMONTH (11)
281+
#define JULIAN_MINDAY (23)
282+
283+
#define IS_VALID_JULIAN(y,m,d) ((y > JULIAN_MINYEAR) \
284+
|| ((y == JULIAN_MINYEAR) && ((m > JULIAN_MINMONTH) \
285+
|| ((m == JULIAN_MINMONTH) && (d >= JULIAN_MINDAY)))))
286+
264287
/*
265288
* dt.c prototypes
266289
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy