zephyr/lib/libc/minimal/source/time/time.c
Gerard Marull-Paretas cbd31d720b lib: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all lib code to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:09 +02:00

29 lines
419 B
C

/*
* Copyright (c) 2021 Golioth, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <time.h>
/* clock_gettime() prototype */
#include <zephyr/posix/time.h>
time_t time(time_t *tloc)
{
struct timespec ts;
int ret;
ret = clock_gettime(CLOCK_REALTIME, &ts);
if (ret < 0) {
/* errno is already set by clock_gettime */
return (time_t) -1;
}
if (tloc) {
*tloc = ts.tv_sec;
}
return ts.tv_sec;
}