fix and simplify time offset

This commit is contained in:
Hiltjo Posthuma 2016-05-06 12:01:57 +02:00
parent c6e8f9fd80
commit 6e5e218b69

View file

@ -297,19 +297,18 @@ printtime(FILE *fp, const git_time *intime)
{ {
struct tm *intm; struct tm *intm;
time_t t; time_t t;
int offset, sign = '+';
char out[32]; char out[32];
offset = intime->offset * 60; t = (time_t)intime->time + (intime->offset * 60);
t = (time_t)intime->time + offset;
if (!(intm = gmtime(&t))) if (!(intm = gmtime(&t)))
return; return;
strftime(out, sizeof(out), "%a %b %e %H:%M:%S", intm); strftime(out, sizeof(out), "%a %b %e %H:%M:%S", intm);
if (offset < 0) { if (intime->offset < 0)
offset = -offset; fprintf(fp, "%s -%02d%02d", out,
sign = '-'; -(intime->offset) / 60, -(intime->offset) % 60);
} else
fprintf(fp, "%s %c%02d%02d", out, sign, offset / 60, offset % 60); fprintf(fp, "%s +%02d%02d", out,
intime->offset / 60, intime->offset % 60);
} }
void void