diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2019-11-13 03:44:50 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-12-07 00:44:19 +0300 |
commit | 18723117271370e480f8ca9495f8850522fabb74 (patch) | |
tree | d882979cd6cfe470c3aa9c20d1f7eaa38d5cc95f /lib | |
parent | 05429b6cf5b3f30f773b8e79fe4cd3688349d7d2 (diff) | |
download | u-boot-18723117271370e480f8ca9495f8850522fabb74.tar.xz |
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 <takahiro.akashi@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/date.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/date.c b/lib/date.c index 63af4a1426..0456de78ab 100644 --- a/lib/date.c +++ b/lib/date.c @@ -8,6 +8,7 @@ #include <command.h> #include <errno.h> #include <rtc.h> +#include <linux/time.h> #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 |