From: Crystal Kolipe Subject: Re: MATE Clock Panel App Glitch To: tech@openbsd.org, quadsix50@gmail.com, robert@openbsd.org Date: Fri, 28 Nov 2025 13:55:04 +0000 On Fri, Nov 28, 2025 at 10:37:38AM +0000, Stuart Henderson wrote: > taking a cue from libc's "support" for %E/%O (C99 locale modifiers > which are recognised but ignored) here's a diff to ignore the modifiers > so at least we'd get something sensible printed in these cases. (if > testing with date(1) note that it's statically linked). would this > or something like it make sense? It's not much more complicated to actually implement the modifiers... Here is a quick example diff to add them to %I in strftime.c which should fix the OP's specific problem. Is there any reason not to implement them for other conversion characters? --- lib/libc/time/strftime.c.dist Fri May 16 14:24:39 2025 +++ lib/libc/time/strftime.c Fri Nov 28 13:46:25 2025 @@ -129,7 +129,11 @@ static char * _fmt(const char *format, const struct tm *t, char *pt, const char *ptlim, int *warnp) { + char fmt_mod; + char * fmt; + for ( ; *format; ++format) { + fmt_mod = 0; if (*format == '%') { label: switch (*++format) { @@ -211,9 +215,21 @@ pt = _conv(t->tm_hour, "%02d", pt, ptlim); continue; case 'I': + switch (fmt_mod) { + case '_': + fmt = "%2d"; + break; + case '-': + fmt = "%d"; + break; + case '0': + default: + fmt = "%02d"; + break; + } pt = _conv((t->tm_hour % 12) ? (t->tm_hour % 12) : 12, - "%02d", pt, ptlim); + fmt, pt, ptlim); continue; case 'j': pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); @@ -477,6 +493,11 @@ pt = _fmt(Locale->date_fmt, t, pt, ptlim, warnp); continue; + case '0': + case '_': + case '-': + fmt_mod = *format; + goto label; case '%': /* ** X311J/88-090 (4.12.3.5): if conversion char is