1 /*
2  * Copyright (c) 2017 Intel Corporation
3  * Copyright (c) 2019 Peter Bigot Consulting, LLC
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_TIME_H_
9 #define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_TIME_H_
10 
11 #include <stdint.h>
12 #include <zephyr/toolchain.h>
13 #include <sys/_types.h>
14 #include <sys/_timespec.h>
15 
16 /* Minimal time.h to fulfill the requirements of certain libraries
17  * like mbedTLS and to support time APIs.
18  */
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 struct tm {
25 	int tm_sec;
26 	int tm_min;
27 	int tm_hour;
28 	int tm_mday;
29 	int tm_mon;
30 	int tm_year;
31 	int tm_wday;
32 	int tm_yday;
33 	int tm_isdst;
34 };
35 
36 #if !defined(__time_t_defined)
37 #define __time_t_defined
38 typedef _TIME_T_ time_t;
39 #endif
40 
41 #if !defined(__suseconds_t_defined)
42 #define __suseconds_t_defined
43 typedef _SUSECONDS_T_ suseconds_t;
44 #endif
45 
46 /*
47  * Conversion between civil time and UNIX time.  The companion
48  * mktime() is not provided here since it
49  * require access to time zone information.
50  *
51  * The localtime() & localtime_r() simply
52  * wraps around the gmtime() & gmtime_r() functions, the
53  * results are always expressed as UTC.
54  */
55 struct tm *gmtime(const time_t *timep);
56 struct tm *gmtime_r(const time_t *ZRESTRICT timep,
57 		    struct tm *ZRESTRICT result);
58 char *asctime(const struct tm *timeptr);
59 struct tm *localtime(const time_t *timer);
60 char *ctime(const time_t *clock);
61 char *asctime_r(const struct tm *ZRESTRICT tp, char *ZRESTRICT buf);
62 char *ctime_r(const time_t *clock, char *buf);
63 struct tm *localtime_r(const time_t *ZRESTRICT timer, struct tm *ZRESTRICT result);
64 
65 time_t time(time_t *tloc);
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDIO_H_ */
72