(fmttime2822): Changed return type for strftime() to size_t.
(fmttime2822) [_WIN32]: %T is not support option for strftime in WIN32 replaced with %H:%M:%S. Replaced %z in with +/-???? format for WIN32 as the default for WIN32 is the text description for timezone.
This commit is contained in:
parent
f691a07814
commit
ce6a691126
1 changed files with 29 additions and 1 deletions
|
@ -37,6 +37,10 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include "file.h"
|
||||
#include "game.h"
|
||||
|
@ -715,9 +719,33 @@ static char *
|
|||
fmttime2822(time_t t)
|
||||
{
|
||||
static char buf[32];
|
||||
int n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
|
||||
localtime(&t));
|
||||
if (CANT_HAPPEN(n == 0))
|
||||
#if defined(_WIN32)
|
||||
size_t n;
|
||||
int nn;
|
||||
TIME_ZONE_INFORMATION tzi;
|
||||
long time_offset;
|
||||
struct tm time;
|
||||
|
||||
localtime_s(&time, &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_s(buf + n, sizeof(buf) - n, sizeof(buf) - n -1,
|
||||
" %+03d%02d", time_offset/60, abs(time_offset) % 60);
|
||||
if (CANT_HAPPEN(nn <= 0))
|
||||
buf[0] = 0;
|
||||
#else
|
||||
size_t int n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
|
||||
localtime(&t));
|
||||
if (CANT_HAPPEN(n == 0))
|
||||
buf[0] = 0;
|
||||
#endif
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue