Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
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
21extern "C" {
22#endif
23
24struct tm {
25 int tm_sec;
26 int tm_min;
29 int tm_mon;
34};
35
36#if !defined(__time_t_defined)
37#define __time_t_defined
38typedef _TIME_T_ time_t;
39#endif
40
41#if !defined(__suseconds_t_defined)
42#define __suseconds_t_defined
43typedef _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 */
55struct tm *gmtime(const time_t *timep);
56struct tm *gmtime_r(const time_t *ZRESTRICT timep,
57 struct tm *ZRESTRICT result);
58char *asctime(const struct tm *timeptr);
59struct tm *localtime(const time_t *timer);
60char *ctime(const time_t *clock);
61char *asctime_r(const struct tm *ZRESTRICT tp, char *ZRESTRICT buf);
62char *ctime_r(const time_t *clock, char *buf);
63struct tm *localtime_r(const time_t *ZRESTRICT timer, struct tm *ZRESTRICT result);
64
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDIO_H_ */
_TIME_T_ time_t
Definition _timespec.h:14
_SUSECONDS_T_ suseconds_t
Definition _timespec.h:19
#define ZRESTRICT
Definition common.h:36
char * asctime(const struct tm *timeptr)
char * ctime(const time_t *clock)
struct tm * localtime_r(const time_t *ZRESTRICT timer, struct tm *ZRESTRICT result)
struct tm * localtime(const time_t *timer)
struct tm * gmtime(const time_t *timep)
char * asctime_r(const struct tm *ZRESTRICT tp, char *ZRESTRICT buf)
time_t time(time_t *tloc)
char * ctime_r(const time_t *clock, char *buf)
struct tm * gmtime_r(const time_t *ZRESTRICT timep, struct tm *ZRESTRICT result)
Definition time.h:24
int tm_mon
Definition time.h:29
int tm_year
Definition time.h:30
int tm_hour
Definition time.h:27
int tm_sec
Definition time.h:25
int tm_isdst
Definition time.h:33
int tm_yday
Definition time.h:32
int tm_mday
Definition time.h:28
int tm_min
Definition time.h:26
int tm_wday
Definition time.h:31
Macros to abstract toolchain specific capabilities.