]> git.armaanb.net Git - stagit.git/commitdiff
fix and simplify time offset
authorHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 6 May 2016 10:01:57 +0000 (12:01 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 6 May 2016 10:01:57 +0000 (12:01 +0200)
stagit.c

index 0d36abc4fea9244901a72b1c59b7f92fc41945c5..d4dd7a5dda9c7a3258d8be3308fcc930a9c63b3e 100644 (file)
--- 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