From 95f131c3c25c10f9a864ba72a7b1586bb31f5df3 Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Tue, 20 Jun 2023 20:35:05 -0300 Subject: [PATCH] lib_strftime: Fix %I to avoid printing 00:xx AM/PM Currently strftime is printing 00:00 AM and 00:00 PM instead of 12:00 AM and 12:00 PM when using %I. This commit fixes this issue! --- 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 43be9a03d8..f8342c2d67 100644 --- a/libs/libc/time/lib_strftime.c +++ b/libs/libc/time/lib_strftime.c @@ -267,7 +267,8 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, case 'I': { - len = snprintf(dest, chleft, "%02d", tm->tm_hour % 12); + len = snprintf(dest, chleft, "%02d", (tm->tm_hour % 12) != 0 ? + (tm->tm_hour % 12) : 12); } break;