simplify time format
1 files changed, 15 insertions(+), 38 deletions(-) | |||
---|---|---|---|
M | urmoms.c | +15 | -38 |
1@@ -48,7 +48,6 @@ commitinfo_free(struct commitinfo *ci)
2 if (!ci)
3 return;
4
5- /* TODO: print error ? */
6 git_diff_stats_free(ci->stats);
7 git_diff_free(ci->diff);
8 git_commit_free(ci->commit);
9@@ -188,56 +187,34 @@ xbasename(const char *path)
10 }
11
12 void
13-printtimez(FILE *fp, const git_time *intime)
14+printtimeformat(FILE *fp, const git_time *intime, const char *fmt)
15 {
16 struct tm *intm;
17 time_t t;
18- int offset, hours, minutes;
19- char sign, out[32];
20-
21- offset = intime->offset;
22- if (offset < 0) {
23- sign = '-';
24- offset = -offset;
25- } else {
26- sign = '+';
27- }
28-
29- hours = offset / 60;
30- minutes = offset % 60;
31+ char out[32];
32
33 t = (time_t) intime->time + (intime->offset * 60);
34-
35 intm = gmtime(&t);
36- strftime(out, sizeof(out), "%Y-%m-%dT%H:%M:%SZ", intm);
37+ strftime(out, sizeof(out), fmt, intm);
38 fputs(out, fp);
39 }
40
41 void
42-printtime(FILE *fp, const git_time *intime)
43+printtimez(FILE *fp, const git_time *intime)
44 {
45- struct tm *intm;
46- time_t t;
47- int offset, hours, minutes;
48- char sign, out[32];
49-
50- offset = intime->offset;
51- if (offset < 0) {
52- sign = '-';
53- offset = -offset;
54- } else {
55- sign = '+';
56- }
57-
58- hours = offset / 60;
59- minutes = offset % 60;
60-
61- t = (time_t) intime->time + (intime->offset * 60);
62+ printtimeformat(fp, intime, "%Y-%m-%dT%H:%M:%SZ");
63+}
64
65- intm = gmtime(&t);
66- strftime(out, sizeof(out), "%a %b %e %T %Y", intm);
67+void
68+printtime(FILE *fp, const git_time *intime)
69+{
70+ printtimeformat(fp, intime, "%a %b %e %T %Y");
71+}
72
73- fprintf(fp, "%s %c%02d%02d", out, sign, hours, minutes);
74+void
75+printtimeshort(FILE *fp, const git_time *intime)
76+{
77+ printtimeformat(fp, intime, "%Y-%m-%d %H:%M");
78 }
79
80 void