[notmuch] [PATCH] Make the date parser nicer

Sebastian Spaeth Sebastian at SSpaeth.de
Tue Jan 26 03:50:41 PST 2010


On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard <keithp at keithp.com> wrote:
> Here's some code which further improves date parsing by allowing lots of
> date formats, including things like "today", "thisweek", ISO and US date
> formats and month names. You can separate two dates with .. to make a
> range, or you can just use the default range ("lastmonth" is everything
> From the 1st of the previous month to the 1st of the current month).
> 
> I think this fits nicely with your code.

It fit nicely indeed. I have just integrated your date parser into my
code and sent it as a series of 4 patches based on current cworth
master. (commits 2565fc6 and 96e11c3 will not compile on their own)

ec3c79a integrate keithp's date.c into the notmuch date parser and delete my previous own 
2565fc6 compile date.c as well
96e11c3 add date parser file from Keith
6ed2569 Make the date parser nicer.

The topic branch is here for those who don't want to apply mail patches:
http://github.com/spaetz/notmuch-all-feature/commits/dateparser3

Documentation of the new notmuch_parse_date function:
/* Parse a string into the first and last possible timestamps.
 * It parses the possible formats and stops if one pattern matches.
 * Keywords: 'today','yesterday','thisweek','lastweek','thismonth',
 *           'lastmonth'
 * Month-day : month[-day]] (month: January, Jan, or 1)\n"
 * ISO format: year[-month[-day]]
 * US format : month[/day[/year]]
 *
 * 'after' is used to fill in bits from context if left out, e.g. a
 * 'date:2004..01' will find from 2004-01-01 through 2004-01-31
 *
 * Return values:
 * NOTMUCH_STATUS_SUCCESS
 * NOTMUCH_STATUS_INVALID_DATE: Error parsing the date string

Please pull :-).

Sebastian


More information about the notmuch mailing list