Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 29 Oct 2020 10:45:26 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: %l missing in strftime()

On Thu, Oct 29, 2020 at 10:02:59AM -0400, Dj Padzensky wrote:
> 
> Hi there-
> 
> Long time fan, first time caller…  :-)
> 
> I noticed that, despite the man page’s claim, %l (that’s ell) is not
> implemented in strftime(). This patch should do the job.
> 
> diff --git a/src/time/strftime.c b/src/time/strftime.c
> index cc53d536..78f12ae0 100644
> --- a/src/time/strftime.c
> +++ b/src/time/strftime.c
> @@ -104,6 +104,12 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
>                 val = tm->tm_yday+1;
>                 width = 3;
>                 goto number;
> +       case 'l':
> +               def_pad = '_';
> +               val = tm->tm_hour;
> +               if (!val) val = 12;
> +               else if (val > 12) val -= 12;
> +               goto number;
>         case 'm':
>                 val = tm->tm_mon+1;
>                 goto number;

The 'l' format is outside the standard, but might be okay to add if we
can be reasonably sure it's not going to conflict with future standard
development.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.