date_relative in notmuch-search

Patrick Totzke patricktotzke at googlemail.com
Thu Jul 14 15:22:58 PDT 2011


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110714/affd94b3/attachment.pgp>


More information about the notmuch mailing list