1 /*
2  * Copyright (c) 2021 Golioth, Inc.
3  * Copyright (c) 2025 Tenstorrent AI ULC
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <time.h>
9 
10 #include <zephyr/sys/clock.h>
11 
time(time_t * tloc)12 time_t time(time_t *tloc)
13 {
14 	struct timespec ts;
15 	int ret;
16 
17 	ret = sys_clock_gettime(SYS_CLOCK_REALTIME, &ts);
18 	if (ret < 0) {
19 		return (time_t) -1;
20 	}
21 
22 	if (tloc) {
23 		*tloc = ts.tv_sec;
24 	}
25 
26 	return ts.tv_sec;
27 }
28