From 37bf8e3c7d82b41141f601d73a630c717e380dbe Mon Sep 17 00:00:00 2001 From: ccli8 Date: Thu, 21 Sep 2017 16:42:00 +0800 Subject: [PATCH] Fix RTC hour error with AM/PM --- targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c index c683629137..a4a6bc0675 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c @@ -87,6 +87,9 @@ time_t rtc_read(void) timeinfo.tm_mday = rtc_datetime.u32Day; timeinfo.tm_wday = rtc_datetime.u32DayOfWeek; timeinfo.tm_hour = rtc_datetime.u32Hour; + if (rtc_datetime.u32TimeScale == RTC_CLOCK_12 && rtc_datetime.u32AmPm == RTC_PM) { + timeinfo.tm_hour += 12; + } timeinfo.tm_min = rtc_datetime.u32Minute; timeinfo.tm_sec = rtc_datetime.u32Second;