From 096aee2bb468d1ab044de36e176ed1f6c7e3674d Mon Sep 17 00:00:00 2001 From: Ron Yorston <rmy@pobox.com> Date: Sat, 9 Dec 2017 09:17:19 +0000 Subject: date: support '-' format flag to remove zero padding The strftime provided by the Microsoft C runtime uses '#' as the format string flag to remove zero padding; glibc uses '-'. Support the use of the '-' flag for improved compatibility. --- win32/mingw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/win32/mingw.c b/win32/mingw.c index afcb6c6d2..a55fb4f40 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -905,6 +905,11 @@ size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm t = newfmt + m + 1; fmt = newfmt; } + else if ( t[1] == '-' && t[2] != '\0' && + strchr("dHIjmMSUwWyY", t[2]) ) { + /* Microsoft uses '#' rather than '-' to remove padding */ + t[1] = '#'; + } else if ( t[1] != '\0' ) { ++t; } -- cgit v1.2.3-55-g6feb