[RFC PATCH 0/2] natural language date range search

Tomi Ollila tomi.ollila at iki.fi
Sat Feb 25 07:05:44 PST 2012


On Mon, 20 Feb 2012 00:55:50 +0200, Jani Nikula <jani at nikula.org> wrote:
> Hi all, these patches add support for natural language date range search
> of the form date:since..until, where since and until can be fairly free
> form date/time expressions in English.
> 
> Examples:
> 
> date:two-days..yesterday (all mail in the two days before today)
> date:12h.. (all mail since 12 hrs ago)
> date:november..november (all mail in previous november)
> date:2011.. (all mail since the beginning of 2011)
> date:last-week..this-week (all mail over last and current week)
> date:5/10/2011-12:34:55..10pm_2012-01-14
> 
> Plus plenty more and combinations of the above.

Pretty c00l, the above and the code.

> 
> The repository for the date/time parser with a command line tool is at
> [1], and there's a README [2] with a bunch of details too.

By seeing the thoughts thrown in IRC there seems to be plenty if things
to resolve until something like this is going to be available in stock
notmuch. In the meanwhile I provide some ideas into the soup; maybe
our collective mind can have some use of this.


Q: Could 'date:timestr' be converted to 'date:timestr..timestr' ?

In this idea -<timestr> means relative time and <timestr> absolute
time. The the time string consists of number and letter and assume
the above suggestion for date:timestr (<- == date:timestr..timestr)
Letters are s seconds  h hours  d days  w weeks  m months (more
useful than for minutes) and  y years.

date:-2000s     email exactly 2000 seconds ago (not very useful)
date:-2000s..   since 2000 secs in past
date:..-2000s   up to 2000 secs in past

date:3600s      email with date 01:00 -- today if (local) time is
                more than 1am. yesterday if less. If there is not
                mail with date exactly that then no email matches
                (i.e. same usefullness applies as above)
date:3600s..    email with date since 01:00 (same today/yesterday
                resolvation like above)

date:12h..      since noon, either yesterday (time less than 12pm)
                or today (currently afternoon)
date:12h        like above, but since 12:00 to 13:00
date:12h..12h   ditto

date:6pm..      since 18:00 either today (current time > 6pm) or yesterday

date:-12h..     since 12 hours ago
date:-12h       since 12 hours ago to 11 hours ago

date:-1h        last hour
date:0h         today 12am - 01am 

date:-0d        today
date:-0d..      ditto
date:-1d        yesterday
date:-1d..      yesterday & today

date:-2d        2 days ago
date:-2d..      day before yesterday, yesterday & today

date:0d         last sunday (if today sunday, today (so being consistent))
date:1d         last monday (like above)
date:6d         last saturday (like above)
date:7d         last sunday (same as 0d)

date:-0w        current week (does week start sun or mon)
date:-1w        last week (same as above)
date:-2w..      since beginning of 2 weeks ago

date:1w         (ISO) week number ? current week it this is same week  
                number. this week last year if current week is less.
date:1w..	since the above date resolved.

date:11m	last november (m is more useable in month than in minute)
date:11m..      since last november

date:-11m       whole month 11 months ago
date:-11m..	since beginning of 11 months ago

date:70y	year 1970
date:69y        year 2069
date:0y         year 2000
date:99y..      since beginning of 1999

date:-0y        this year
date:-1y        last year


This is incomplete, but pretty easy to use format. Letters from English
language. What is missing letter for month (M?) ar mday (D?). All thought
as in local time...

... strings could be concatenated: for example: -3d11h (meaning second
always absolute). Need to be in granularity order (or something). Timezone
could be added (pst, utc, eest, z -- and even like -11 or +4
( -2y11m+7 meaning year 2010 november in timezone utc + 7 (this year: 2012))

Of course range date:-2d..-5h would be supported.

> BR,
> Jani.
> 
> 
> [1] https://gitorious.org/parse-time-string/parse-time-string
> [2] https://gitorious.org/parse-time-string/parse-time-string/blobs/master/README
> 

Tomi



More information about the notmuch mailing list