show: Drop Windows-specific fmttime2822() code

fmttime2822() works around Windows strftime() lacking %z and %T.  This
is no longer the case, although MinGW still warns about %T.  Replace
%T by the %H:%M:%S, and drop the work-around.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2021-01-27 08:43:24 +01:00
parent b19aa1c13f
commit 598669673e

View file

@ -615,34 +615,10 @@ static char *
fmttime2822(time_t t) fmttime2822(time_t t)
{ {
static char buf[32]; static char buf[32];
#if defined(_WIN32) size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %z",
size_t n;
int nn;
TIME_ZONE_INFORMATION tzi;
long time_offset;
struct tm *time;
time = localtime(&t);
n = strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S", time);
if (CANT_HAPPEN(n == 0)) {
buf[0] = 0;
return buf;
}
GetTimeZoneInformation(&tzi);
time_offset = -(tzi.Bias +
(time->tm_isdst ? tzi.DaylightBias : tzi.StandardBias));
nn = _snprintf(buf + n, sizeof(buf) - n, " %+03ld%02ld",
time_offset / 60, labs(time_offset) % 60);
if (CANT_HAPPEN(nn <= 0 || nn + n >= sizeof(buf)))
buf[0] = 0;
#else
size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
localtime(&t)); localtime(&t));
if (CANT_HAPPEN(n == 0)) if (CANT_HAPPEN(n == 0))
buf[0] = 0; buf[0] = 0;
#endif
return buf; return buf;
} }