mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] %l missing in strftime()
Date: Thu, 29 Oct 2020 10:45:26 -0400	[thread overview]
Message-ID: <20201029144526.GP534@brightrain.aerifal.cx> (raw)
In-Reply-To: <3D3DD419-84C6-437A-930A-EAD6777C0130@padz.net>

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

      reply	other threads:[~2020-10-29 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 14:02 Dj Padzensky
2020-10-29 14:45 ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201029144526.GP534@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).