date_relative in notmuch-search

Subject: date_relative in notmuch-search

Date: Thu, 14 Jul 2011 23:22:58 +0100

To: notmuch@notmuchmail.org

Cc:

From: Patrick Totzke


Hi,

I wodered why "notmuch search --format=json" doesn't provide the "date_relative" field for
results, as the show command does.

I'm not expert on notmuch internals but I got it working like this:

diff --git a/notmuch-search.c b/notmuch-search.c
index faccaf7..b1adc03 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -176,12 +176,14 @@ format_thread_json (const void *ctx,
 
     printf ("\"thread\": %s,\n"
            "\"timestamp\": %ld,\n"
+           "\"date_relative\": \"%s\",\n"
            "\"matched\": %d,\n"
            "\"total\": %d,\n"
            "\"authors\": %s,\n"
            "\"subject\": %s,\n",
            json_quote_str (ctx_quote, thread_id),
            date,
+           notmuch_time_relative_date (ctx, date),

I'm unsure it it's better to use json_quote_str here but you tell me :)
Best,
/p
signature.asc (application/pgp-signature)

Thread: