define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / test / time.c
blobb5182232fa519b76bea47fd7b0e6a6333b142276
1 #include <stdio.h>
2 #include <time.h>
4 int main(int argc, char **argv) {
5 time_t now, mk;
6 char buf[26], *pbuf;
7 struct tm tm;
9 now = time(NULL);
10 printf("time: %d\n", now);
12 pbuf = ctime(&now);
13 printf("ctime: %s", pbuf);
14 pbuf = ctime_r(&now, &buf);
15 printf("ctime_r: %s", buf);
17 mk = mktime(gmtime(&now));
18 printf("gmtime: %d\n", mk);
19 mk = mktime(gmtime_r(&now, &tm));
20 printf("gmtime_r: %d\n", mk);
22 mk = mktime(localtime(&now));
23 printf("localtime: %d\n", mk);
24 mk = mktime(localtime_r(&now, &tm));
25 printf("localtime_r: %d\n", mk);
27 pbuf = asctime(&tm);
28 printf("asctime: %s", pbuf);
29 pbuf = asctime_r(&tm, &buf);
30 printf("asctime_r: %s", buf);
32 return 0;