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!
This commit is contained in:
Alan Carvalho de Assis 2023-06-20 20:35:05 -03:00 committed by Xiang Xiao
parent 1a06f7a2c9
commit 95f131c3c2
1 changed files with 2 additions and 1 deletions

View File

@ -267,7 +267,8 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format,
case 'I': 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; break;