From 94eefdee2f5db36d52e817a01b07c8255527e193 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Apr 2015 12:37:22 -0600 Subject: dm: sandbox: Add os_localtime() to obtain the system time Add a function to read the system time into U-Boot. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'arch/sandbox/cpu/os.c') diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 4d5f805753..e6dd17e9ef 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -24,6 +24,7 @@ #include #include #include +#include /* Operating System Interface */ @@ -537,3 +538,20 @@ int os_jump_to_image(const void *dest, int size) return unlink(fname); } + +void os_localtime(struct rtc_time *rt) +{ + time_t t = time(NULL); + struct tm *tm; + + tm = localtime(&t); + rt->tm_sec = tm->tm_sec; + rt->tm_min = tm->tm_min; + rt->tm_hour = tm->tm_hour; + rt->tm_mday = tm->tm_mday; + rt->tm_mon = tm->tm_mon + 1; + rt->tm_year = tm->tm_year + 1900; + rt->tm_wday = tm->tm_wday; + rt->tm_yday = tm->tm_yday; + rt->tm_isdst = tm->tm_isdst; +} -- cgit v1.2.1