2N/A * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 2N/A * Copyright (c) 1999 by Internet Software Consortium. 2N/A * Permission to use, copy, modify, and distribute this software for any 2N/A * purpose with or without fee is hereby granted, provided that the above 2N/A * copyright notice and this permission notice appear in all copies. 2N/A * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 2N/A * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 2N/A * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 2N/A * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 2N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 2N/A * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 2N/A * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 2N/Astatic int datepart(
const char *,
int,
int,
int,
int *);
2N/A * Convert a date in ASCII into the number of seconds since 2N/A * 1 January 1970 (GMT assumed). Format is yyyymmddhhmmss, all 2N/A * digits required, no spaces allowed. 2N/A {
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31};
2N/A if (*
errp)
/*%< Any parse errors? */ 2N/A * OK, now because timegm() is not available in all environments, 2N/A * we will do it by hand. Roll up sleeves, curse the gods, begin! 2N/A#
define isleap(y) ((((y) %
4) == 0 && ((y) %
100) != 0) || ((y) %
400) == 0)
2N/A /* Months are trickier. Look without leaping, then leap */ 2N/A /* First figure years without leapdays, then add them in. */ 2N/A /* The loop is slow, FIXME, but simple and accurate. */ 2N/A * Parse part of a date. Set error flag if any error. 2N/A * Don't reset the flag if there is no error.