]> git.ipfire.org Git - thirdparty/git.git/blobdiff - date.c
PRItime: introduce a new "printf format" for timestamps
[thirdparty/git.git] / date.c
diff --git a/date.c b/date.c
index 495c207c64f5bced30661991d4c46edeadfa1184..5c33dfd8ee79a49ea96241489720e9b2a4fe0fc4 100644 (file)
--- a/date.c
+++ b/date.c
@@ -100,41 +100,41 @@ void show_date_relative(unsigned long time, int tz,
        diff = now->tv_sec - time;
        if (diff < 90) {
                strbuf_addf(timebuf,
-                        Q_("%lu second ago", "%lu seconds ago", diff), diff);
+                        Q_("%"PRItime" second ago", "%"PRItime" seconds ago", diff), diff);
                return;
        }
        /* Turn it into minutes */
        diff = (diff + 30) / 60;
        if (diff < 90) {
                strbuf_addf(timebuf,
-                        Q_("%lu minute ago", "%lu minutes ago", diff), diff);
+                        Q_("%"PRItime" minute ago", "%"PRItime" minutes ago", diff), diff);
                return;
        }
        /* Turn it into hours */
        diff = (diff + 30) / 60;
        if (diff < 36) {
                strbuf_addf(timebuf,
-                        Q_("%lu hour ago", "%lu hours ago", diff), diff);
+                        Q_("%"PRItime" hour ago", "%"PRItime" hours ago", diff), diff);
                return;
        }
        /* We deal with number of days from here on */
        diff = (diff + 12) / 24;
        if (diff < 14) {
                strbuf_addf(timebuf,
-                        Q_("%lu day ago", "%lu days ago", diff), diff);
+                        Q_("%"PRItime" day ago", "%"PRItime" days ago", diff), diff);
                return;
        }
        /* Say weeks for the past 10 weeks or so */
        if (diff < 70) {
                strbuf_addf(timebuf,
-                        Q_("%lu week ago", "%lu weeks ago", (diff + 3) / 7),
+                        Q_("%"PRItime" week ago", "%"PRItime" weeks ago", (diff + 3) / 7),
                         (diff + 3) / 7);
                return;
        }
        /* Say months for the past 12 months or so */
        if (diff < 365) {
                strbuf_addf(timebuf,
-                        Q_("%lu month ago", "%lu months ago", (diff + 15) / 30),
+                        Q_("%"PRItime" month ago", "%"PRItime" months ago", (diff + 15) / 30),
                         (diff + 15) / 30);
                return;
        }
@@ -145,20 +145,20 @@ void show_date_relative(unsigned long time, int tz,
                unsigned long months = totalmonths % 12;
                if (months) {
                        struct strbuf sb = STRBUF_INIT;
-                       strbuf_addf(&sb, Q_("%lu year", "%lu years", years), years);
+                       strbuf_addf(&sb, Q_("%"PRItime" year", "%"PRItime" years", years), years);
                        strbuf_addf(timebuf,
                                 /* TRANSLATORS: "%s" is "<n> years" */
-                                Q_("%s, %lu month ago", "%s, %lu months ago", months),
+                                Q_("%s, %"PRItime" month ago", "%s, %"PRItime" months ago", months),
                                 sb.buf, months);
                        strbuf_release(&sb);
                } else
                        strbuf_addf(timebuf,
-                                Q_("%lu year ago", "%lu years ago", years), years);
+                                Q_("%"PRItime" year ago", "%"PRItime" years ago", years), years);
                return;
        }
        /* Otherwise, just years. Centuries is probably overkill. */
        strbuf_addf(timebuf,
-                Q_("%lu year ago", "%lu years ago", (diff + 183) / 365),
+                Q_("%"PRItime" year ago", "%"PRItime" years ago", (diff + 183) / 365),
                 (diff + 183) / 365);
 }
 
@@ -179,7 +179,7 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
 
        if (mode->type == DATE_UNIX) {
                strbuf_reset(&timebuf);
-               strbuf_addf(&timebuf, "%lu", time);
+               strbuf_addf(&timebuf, "%"PRItime, time);
                return timebuf.buf;
        }
 
@@ -188,7 +188,7 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
 
        if (mode->type == DATE_RAW) {
                strbuf_reset(&timebuf);
-               strbuf_addf(&timebuf, "%lu %+05d", time, tz);
+               strbuf_addf(&timebuf, "%"PRItime" %+05d", time, tz);
                return timebuf.buf;
        }
 
@@ -643,7 +643,7 @@ static void date_string(unsigned long date, int offset, struct strbuf *buf)
                offset = -offset;
                sign = '-';
        }
-       strbuf_addf(buf, "%lu %c%02d%02d", date, sign, offset / 60, offset % 60);
+       strbuf_addf(buf, "%"PRItime" %c%02d%02d", date, sign, offset / 60, offset % 60);
 }
 
 /*