From 6e3c4aab7d3ca43e604843cb7b791e3224ab1c22 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Tue, 1 Nov 2022 16:42:43 +0800 Subject: [PATCH] alarm: using timegm instead of mktime beacuse rtc is gmt time Signed-off-by: dongjiuzhu1 --- examples/alarm/alarm_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/alarm/alarm_main.c b/examples/alarm/alarm_main.c index ce70123a8..05e5face6 100644 --- a/examples/alarm/alarm_main.c +++ b/examples/alarm/alarm_main.c @@ -334,14 +334,14 @@ int main(int argc, FAR char *argv[]) * alarm expiring in year 1900. */ - timeleft = mktime((struct tm *)&rd.time) - now; + timeleft = timegm((struct tm *)&rd.time) - now; } else { struct tm now_tm; /* Periodic extend "partial" alarms by "unfolding" months, - * until we get alarm that is in future. Note that mktime() + * until we get alarm that is in future. Note that timegm() * normalizes fields that are out of their valid values, * so we don't have to handle carry to tm_year by ourselves. */ @@ -352,7 +352,7 @@ int main(int argc, FAR char *argv[]) do { - timeleft = mktime((struct tm *)&rd.time) - now; + timeleft = timegm((struct tm *)&rd.time) - now; if (timeleft < 0) { rd.time.tm_mon++;