$NetBSD: patch-ad,v 1.2 2006/10/28 15:17:17 schwarz Exp $ --- unctime.y.orig 1999-12-02 03:16:21.000000000 +0100 +++ unctime.y 2006-10-28 13:10:57.000000000 +0200 @@ -80,12 +80,15 @@ # define USE_FTIME # endif #endif +#ifdef HAS_MKTIME +# define USE_MKTIME +#endif #ifdef USE_GETTOD # include #else # include -# ifdef USE_FTIME +# if defined(USE_FTIME) && !defined(NO_SYS_TIMEB_H) # include # endif #endif @@ -331,6 +334,7 @@ /* Is y a leap year? */ #define leap(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0) +#ifndef USE_MKTIME /* Number of leap years from 1970 to y (not including y itself) */ #define nleap(y) (((y) - 1969) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400) @@ -484,6 +488,7 @@ } #endif /* not USE_GETTOD */ +#endif /* not USE_MKTIME */ static short monthlens[] = { @@ -563,6 +568,15 @@ return -1; } +#ifdef USE_MKTIME + tm->tm_year = year - 1900; + tm->tm_mon = month - 1; + tm->tm_mday = day; + tm->tm_hour = hour; + tm->tm_min = minute; + tm->tm_sec = second; + return mktime(tm); +#else /* not USE_MKTIME */ /* Mostly for convenience in sunday() macro, we use zero-origin days. */ dayofyear = day - 1; if (month > 2 && leap(year)) @@ -581,4 +595,5 @@ - correction() #endif ; +#endif /* not USE_MKTIME */ }