zephyr/lib/libc/common/source/time/localtime_r_utc.c
Yong Cong Sin fe94d4354a libc: common: implement multiple time functions
Implemented the following:
- `asctime_r()`
- `asctime()`
- `localtime()`
- `localtime_r()`
- `ctime()`
- `ctime_r()`

Specifically:
- the implementation of `localtime()` & `localtime_r()` simply
  wraps around the gmtime() & gmtime_r() functions, the
  results are always expressed as UTC.
- `ctime()` is equivalent to `asctime(localtime(clock))`, it
  inherits the limitation of `localtime()` as well, which only
  supports UTC results currently.

Added tests for these newly implemented functions.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-08-21 16:59:15 -04:00

17 lines
276 B
C

/*
* Copyright (c) 2024 Meta Platforms
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <time.h>
struct tm *localtime_r(const time_t *timer, struct tm *result)
{
return gmtime_r(timer, result);
}
struct tm *localtime(const time_t *timer)
{
return gmtime(timer);
}