]> granicus.if.org Git - cgit/commitdiff
ui-shared: add cgit_date_mode()
authorJohn Keeping <john@keeping.me.uk>
Tue, 19 Jan 2016 19:33:03 +0000 (19:33 +0000)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 8 Feb 2016 13:21:34 +0000 (14:21 +0100)
This returns the correct mode value for use with Git's show_date() based
on the current CGit configuration and will be used in the following
patches.

Signed-off-by: John Keeping <john@keeping.me.uk>
ui-shared.c
ui-shared.h

index 76aac60fd6defb6562782f3dd07b2448870d775a..923d1025f71f062832a8a7df22b24d2107fa8ad1 100644 (file)
@@ -627,6 +627,15 @@ void cgit_print_date(time_t secs, const char *format, int local_time)
        html_txt(fmt_date(secs, format, local_time));
 }
 
+const struct date_mode *cgit_date_mode(const char *format)
+{
+       static struct date_mode mode;
+       mode.type = DATE_STRFTIME;
+       mode.strftime_fmt = format;
+       mode.local = ctx.cfg.local_time;
+       return &mode;
+}
+
 static void print_rel_date(time_t t, double value,
        const char *class, const char *suffix)
 {
index c9413ede7f769a3d0e3cc858acc2e12168de25d0..707cec9a132acf43a4d6f8a3f6059a55e016d101 100644 (file)
@@ -61,6 +61,7 @@ __attribute__((format (printf,1,2)))
 extern void cgit_print_error(const char *fmt, ...);
 __attribute__((format (printf,1,0)))
 extern void cgit_vprint_error(const char *fmt, va_list ap);
+extern const struct date_mode *cgit_date_mode(const char *format);
 extern void cgit_print_date(time_t secs, const char *format, int local_time);
 extern void cgit_print_age(time_t t, time_t max_relative);
 extern void cgit_print_http_headers(void);