blob: 879610d1ec891cac9aa24c0aa8afd897ea7e6c7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
$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 <sys/time.h>
#else
# include <time.h>
-# ifdef USE_FTIME
+# if defined(USE_FTIME) && !defined(NO_SYS_TIMEB_H)
# include <sys/timeb.h>
# 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 */
}
|