]> git.armaanb.net Git - stagit.git/commitdiff
fix times (and timezone)
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 1 May 2016 14:10:17 +0000 (16:10 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 1 May 2016 14:56:58 +0000 (16:56 +0200)
- in the index and log show the short time (GMT).
- in the Atom feed use GMT time.
- for commits show the time + offset.

stagit-index.c
stagit.c

index 2d7bf8579d303cdd264a1e0cfcaed7023a3bda88..1d26e0f9a37172ef191acd884df3cea1bbd21f92 100644 (file)
@@ -42,25 +42,19 @@ xmlencode(FILE *fp, const char *s, size_t len)
 }
 
 void
-printtimeformat(FILE *fp, const git_time *intime, const char *fmt)
+printtimeshort(FILE *fp, const git_time *intime)
 {
        struct tm *intm;
        time_t t;
        char out[32];
 
-       t = (time_t) intime->time + (intime->offset * 60);
+       t = (time_t)intime->time;
        if (!(intm = gmtime(&t)))
                return;
-       strftime(out, sizeof(out), fmt, intm);
+       strftime(out, sizeof(out), "%Y-%m-%d %H:%M", intm);
        fputs(out, fp);
 }
 
-void
-printtimeshort(FILE *fp, const git_time *intime)
-{
-       printtimeformat(fp, intime, "%Y-%m-%d %H:%M");
-}
-
 int
 writeheader(FILE *fp)
 {
index 24a630d35621e79d2924df6fac2f08d9d09d8cc7..cb2c1c9ddca556c9d1fe7d9e3bd53678d29749fa 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -268,35 +268,51 @@ mkdirp(const char *path)
 }
 
 void
-printtimeformat(FILE *fp, const git_time *intime, const char *fmt)
+printtimez(FILE *fp, const git_time *intime)
 {
        struct tm *intm;
        time_t t;
        char out[32];
 
-       t = (time_t) intime->time + (intime->offset * 60);
+       t = (time_t)intime->time;
        if (!(intm = gmtime(&t)))
                return;
-       strftime(out, sizeof(out), fmt, intm);
+       strftime(out, sizeof(out), "%Y-%m-%dT%H:%M:%SZ", intm);
        fputs(out, fp);
 }
 
-void
-printtimez(FILE *fp, const git_time *intime)
-{
-       printtimeformat(fp, intime, "%Y-%m-%dT%H:%M:%SZ");
-}
-
 void
 printtime(FILE *fp, const git_time *intime)
 {
-       printtimeformat(fp, intime, "%a %b %e %T %Y");
+       struct tm *intm;
+       time_t t;
+       int offset, sign = '+';
+       char out[32];
+
+       offset = intime->offset * 60;
+       t = (time_t)intime->time + offset;
+       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);
 }
 
 void
 printtimeshort(FILE *fp, const git_time *intime)
 {
-       printtimeformat(fp, intime, "%Y-%m-%d %H:%M");
+       struct tm *intm;
+       time_t t;
+       char out[32];
+
+       t = (time_t)intime->time;
+       if (!(intm = gmtime(&t)))
+               return;
+       strftime(out, sizeof(out), "%Y-%m-%d %H:%M", intm);
+       fputs(out, fp);
 }
 
 int