mailing list of musl libc
 help / color / mirror / Atom feed
* [musl] %l missing in strftime()
@ 2020-10-29 14:02 Dj Padzensky
  2020-10-29 14:45 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Dj Padzensky @ 2020-10-29 14:02 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 858 bytes --]


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;


Keep up the great work!

—Dj

[-- Attachment #1.2: Type: text/html, Size: 3772 bytes --]

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4372 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] %l missing in strftime()
  2020-10-29 14:02 [musl] %l missing in strftime() Dj Padzensky
@ 2020-10-29 14:45 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-10-29 14:45 UTC (permalink / raw)
  To: musl

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-29 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 14:02 [musl] %l missing in strftime() Dj Padzensky
2020-10-29 14:45 ` Rich Felker

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ http://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git