From 18723117271370e480f8ca9495f8850522fabb74 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Wed, 13 Nov 2019 09:44:50 +0900 Subject: lib: add mktime64() for linux compatibility This function will be used in lib/crypto/x509_cert_parser.c, which will also be imported from linux code in a later commit. Signed-off-by: AKASHI Takahiro --- lib/date.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/date.c') diff --git a/lib/date.c b/lib/date.c index 63af4a1..0456de7 100644 --- a/lib/date.c +++ b/lib/date.c @@ -8,6 +8,7 @@ #include #include #include +#include #if defined(CONFIG_LIB_DATE) || defined(CONFIG_TIMESTAMP) @@ -97,3 +98,22 @@ unsigned long rtc_mktime(const struct rtc_time *tm) } #endif /* CONFIG_LIB_DATE || CONFIG_TIMESTAMP */ + +#ifdef CONFIG_LIB_DATE +/* for compatibility with linux code */ +time64_t mktime64(const unsigned int year, const unsigned int mon, + const unsigned int day, const unsigned int hour, + const unsigned int min, const unsigned int sec) +{ + struct rtc_time time; + + time.tm_year = year; + time.tm_mon = mon; + time.tm_mday = day; + time.tm_hour = hour; + time.tm_min = min; + time.tm_sec = sec; + + return (time64_t)rtc_mktime((const struct rtc_time *)&time); +} +#endif -- cgit v1.1