From 9b8eedd2186345b08e55960f1d2e048af4cd4736 Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Tue, 20 Jun 2023 21:36:48 -0300 Subject: [PATCH] lib_strftime: Also fix %l to avoid printing 0:xx AM/PM --- libs/libc/time/lib_strftime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/libc/time/lib_strftime.c b/libs/libc/time/lib_strftime.c index f8342c2d675..68836677196 100644 --- a/libs/libc/time/lib_strftime.c +++ b/libs/libc/time/lib_strftime.c @@ -305,7 +305,8 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, case 'l': { - len = snprintf(dest, chleft, "%2d", tm->tm_hour % 12); + len = snprintf(dest, chleft, "%2d", (tm->tm_hour % 12) != 0 ? + (tm->tm_hour % 12) : 12); } break;