logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 184fd9cf78e696a540ed35edc4d9c3dcc739c9c9
parent b70ff3710668d454106d5c47ce92a3f8e69dcfe4
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 20 Dec 2025 17:40:04 +0100

cmd/date: handle characters around %N/%:z

Diffstat:

Mcmd/date.c8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmd/date.c b/cmd/date.c @@ -72,6 +72,7 @@ date_strftime(char *restrict buf, fmt_buf[fmt_bufi] = '\0'; + size_t fmt_bufused = 0; if(fmt_buf[0] == '%' && fmt_buf[1] == ':' && fmt_buf[2] == 'z') { size_t got = snprintf( @@ -81,6 +82,7 @@ date_strftime(char *restrict buf, buf += got; buflen -= got; printed += got; + fmt_bufused += 3; } else if(fmt_buf[0] == '%' && fmt_buf[1] == 'N') { @@ -90,10 +92,12 @@ date_strftime(char *restrict buf, buf += got; buflen -= got; printed += got; + fmt_bufused += 2; } - else + + if(fmt_bufi > fmt_bufused) { - size_t got = strftime(buf, buflen, fmt_buf, tm); + size_t got = strftime(buf, buflen, fmt_buf + fmt_bufused, tm); if(got == 0) return got; buf += got;