From ec93385dfa5bda50b6175567d0949fd2ea8aa16e Mon Sep 17 00:00:00 2001 From: Fotis Panagiotopoulos Date: Tue, 18 Oct 2022 16:29:41 +0300 Subject: [PATCH] strftime: Added support for the %w format specifier. --- libs/libc/time/lib_strftime.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/libc/time/lib_strftime.c b/libs/libc/time/lib_strftime.c index 352b970ab20..2c98ea30e2f 100644 --- a/libs/libc/time/lib_strftime.c +++ b/libs/libc/time/lib_strftime.c @@ -130,6 +130,7 @@ static const char * const g_monthname[12] = * %S The second as a decimal number (range 00 to 60). (The range is * up to 60 to allow for occasional leap seconds.) * %t A tab character. (SU) + * %w The weekday as a decimal number (range 0 to 6). * %y The year as a decimal number without a century (range 00 to 99). * %Y The year as a decimal number including the century. * %% A literal '%' character. @@ -398,6 +399,14 @@ size_t strftime(FAR char *s, size_t max, FAR const char *format, } break; + /* %w: The weekday as a decimal number (range 0 to 6). */ + + case 'w': + { + len = snprintf(dest, chleft, "%d", tm->tm_wday); + } + break; + /* %y: The year as a decimal number without a century * (range 00 to 99). */