simplify time format - stagit-gopher - A git gopher frontend. (mirror) | |
git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2h… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit c5c6741b0a7cc41f1f7976c47d7f41320d57508c | |
parent b1ad5e2633477117f122c95bf39d65a179fb4f2d | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Mon, 7 Dec 2015 23:22:18 +0100 | |
simplify time format | |
Diffstat: | |
M urmoms.c | 53 +++++++++--------------------… | |
1 file changed, 15 insertions(+), 38 deletions(-) | |
--- | |
diff --git a/urmoms.c b/urmoms.c | |
@@ -48,7 +48,6 @@ commitinfo_free(struct commitinfo *ci) | |
if (!ci) | |
return; | |
- /* TODO: print error ? */ | |
git_diff_stats_free(ci->stats); | |
git_diff_free(ci->diff); | |
git_commit_free(ci->commit); | |
@@ -188,56 +187,34 @@ xbasename(const char *path) | |
} | |
void | |
-printtimez(FILE *fp, const git_time *intime) | |
+printtimeformat(FILE *fp, const git_time *intime, const char *fmt) | |
{ | |
struct tm *intm; | |
time_t t; | |
- int offset, hours, minutes; | |
- char sign, out[32]; | |
- | |
- offset = intime->offset; | |
- if (offset < 0) { | |
- sign = '-'; | |
- offset = -offset; | |
- } else { | |
- sign = '+'; | |
- } | |
- | |
- hours = offset / 60; | |
- minutes = offset % 60; | |
+ char out[32]; | |
t = (time_t) intime->time + (intime->offset * 60); | |
- | |
intm = gmtime(&t); | |
- strftime(out, sizeof(out), "%Y-%m-%dT%H:%M:%SZ", intm); | |
+ strftime(out, sizeof(out), fmt, intm); | |
fputs(out, fp); | |
} | |
void | |
-printtime(FILE *fp, const git_time *intime) | |
+printtimez(FILE *fp, const git_time *intime) | |
{ | |
- struct tm *intm; | |
- time_t t; | |
- int offset, hours, minutes; | |
- char sign, out[32]; | |
- | |
- offset = intime->offset; | |
- if (offset < 0) { | |
- sign = '-'; | |
- offset = -offset; | |
- } else { | |
- sign = '+'; | |
- } | |
- | |
- hours = offset / 60; | |
- minutes = offset % 60; | |
- | |
- t = (time_t) intime->time + (intime->offset * 60); | |
+ printtimeformat(fp, intime, "%Y-%m-%dT%H:%M:%SZ"); | |
+} | |
- intm = gmtime(&t); | |
- strftime(out, sizeof(out), "%a %b %e %T %Y", intm); | |
+void | |
+printtime(FILE *fp, const git_time *intime) | |
+{ | |
+ printtimeformat(fp, intime, "%a %b %e %T %Y"); | |
+} | |
- fprintf(fp, "%s %c%02d%02d", out, sign, hours, minutes); | |
+void | |
+printtimeshort(FILE *fp, const git_time *intime) | |
+{ | |
+ printtimeformat(fp, intime, "%Y-%m-%d %H:%M"); | |
} | |
void |