summaryrefslogtreecommitdiff
path: root/stagit.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-05-06 12:01:57 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-05-06 12:01:57 +0200
commit6e5e218b697ffb8ff1819cbc3b8783f9a7270de2 (patch)
tree64f8163970a696355d17b251f5b70871ed3a3c21 /stagit.c
parentc6e8f9fd809cc16960022c344b42be77229a70c6 (diff)
fix and simplify time offset
Diffstat (limited to 'stagit.c')
-rw-r--r--stagit.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/stagit.c b/stagit.c
index 0d36abc..d4dd7a5 100644
--- a/stagit.c
+++ b/stagit.c
@@ -297,19 +297,18 @@ printtime(FILE *fp, const git_time *intime)
{
struct tm *intm;
time_t t;
- int offset, sign = '+';
char out[32];
- offset = intime->offset * 60;
- t = (time_t)intime->time + offset;
+ t = (time_t)intime->time + (intime->offset * 60);
if (!(intm = gmtime(&t)))
return;
strftime(out, sizeof(out), "%a %b %e %H:%M:%S", intm);
- if (offset < 0) {
- offset = -offset;
- sign = '-';
- }
- fprintf(fp, "%s %c%02d%02d", out, sign, offset / 60, offset % 60);
+ if (intime->offset < 0)
+ fprintf(fp, "%s -%02d%02d", out,
+ -(intime->offset) / 60, -(intime->offset) % 60);
+ else
+ fprintf(fp, "%s +%02d%02d", out,
+ intime->offset / 60, intime->offset % 60);
}
void