From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A6E0D431FBD for ; Sat, 25 Feb 2012 21:05:23 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Unj1Q7302c8t for ; Sat, 25 Feb 2012 21:05:22 -0800 (PST) Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 269FD431FAE for ; Sat, 25 Feb 2012 21:05:21 -0800 (PST) Received: by lahd3 with SMTP id d3so4359286lah.26 for ; Sat, 25 Feb 2012 21:05:19 -0800 (PST) Received-SPF: pass (google.com: domain of jani@nikula.org designates 10.152.123.68 as permitted sender) client-ip=10.152.123.68; Authentication-Results: mr.google.com; spf=pass (google.com: domain of jani@nikula.org designates 10.152.123.68 as permitted sender) smtp.mail=jani@nikula.org Received: from mr.google.com ([10.152.123.68]) by 10.152.123.68 with SMTP id ly4mr6923784lab.13.1330232719286 (num_hops = 1); Sat, 25 Feb 2012 21:05:19 -0800 (PST) Received: by 10.152.123.68 with SMTP id ly4mr5018536lab.13.1330199611811; Sat, 25 Feb 2012 11:53:31 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi. [84.248.80.253]) by mx.google.com with ESMTPS id w10sm10806424lbe.14.2012.02.25.11.53.29 (version=SSLv3 cipher=OTHER); Sat, 25 Feb 2012 11:53:30 -0800 (PST) From: Jani Nikula To: Tomi Ollila , notmuch@notmuchmail.org Subject: Re: [RFC PATCH 0/2] natural language date range search In-Reply-To: References: User-Agent: Notmuch/0.11.1+206~gc02a53f (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Sat, 25 Feb 2012 21:53:27 +0200 Message-ID: <87ehtiitag.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQk/WIQZLZVu84eW/JEysuCmUfDexFcrGEH+x28jHu4CXUsL1wxC3gQ0dXh2VMvGaWqdzn2U X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Feb 2012 05:05:23 -0000 On Sat, 25 Feb 2012 17:05:44 +0200, Tomi Ollila wrote: > On Mon, 20 Feb 2012 00:55:50 +0200, Jani Nikula 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. Thanks! :) > > > > 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' ? AFAICT this would require the custom query parser. > In this idea - means relative time and 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. I'll put it bluntly: show me the code! ;) I'll comment below how your examples can be expressed with working code in this series, just for comparison, and to show what can be done with this. > date:-2000s email exactly 2000 seconds ago (not very useful) date:2000s..2000s > date:-2000s.. since 2000 secs in past date:2000s.. date:1000s500s500s.. (all accumulated) > date:..-2000s up to 2000 secs in past date:..2000s > 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) Okay, there's no easy way to express it like this. > date:12h.. since noon, either yesterday (time less than 12pm) > or today (currently afternoon) date:noon.. date:12pm.. date:12:00.. date:12:00:00.. (I think in my implementation currently refers to today regardless of current time; there's a REVISIT comment about that. Not difficult to fix.) > date:12h like above, but since 12:00 to 13:00 > date:12h..12h ditto For example date:noon..13:00 > date:6pm.. since 18:00 either today (current time > 6pm) or yesterday The same. > date:-12h.. since 12 hours ago date:12h.. > date:-12h since 12 hours ago to 11 hours ago date:12h..11hrs > date:-1h last hour date:1h.. > date:0h today 12am - 01am For example date:00:00..01am > date:-0d today To cover the whole day, date:today..today > date:-0d.. ditto date:0d..0d (from zero days ago to zero days ago, rounded accordingly) In fact, in my implementation "today" is simply the same as 0 days ago. > date:-1d yesterday date:yesterday..yesterday > date:-1d.. yesterday & today date:1d.. > date:-2d 2 days ago For example date:two-days..2d > date:-2d.. day before yesterday, yesterday & today date:2d.. > date:0d last sunday (if today sunday, today (so being consistent)) date:sunday..sunday (if today sunday, one week ago) > date:1d last monday (like above) > date:6d last saturday (like above) > date:7d last sunday (same as 0d) Just weekday names. > date:-0w current week (does week start sun or mon) For example date:0w...this-week > date:-1w last week (same as above) For example date:last-week..1w > date:-2w.. since beginning of 2 weeks ago date:2w.. > 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. N/A, my parser does not support week numbers. > date:11m last november (m is more useable in month than in minute) date:november..november, or by specifying the year date:2011-11..2011-11 > date:11m.. since last november date:november.. > date:-11m whole month 11 months ago date:11mon..11M (lower case m is minutes) > date:-11m.. since beginning of 11 months ago date:11months.. > date:70y year 1970 date:1970..1970 > date:69y year 2069 date:2069..2069 > date:0y year 2000 date:2000..2000 > date:99y.. since beginning of 1999 date:2000.. (It's possible to use 2-digit years in combination with some more context, e.g. 1.1.99) > date:-0y this year date:this-year..this-year > date:-1y last year date:last-year..1y > 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)) My implementation allows adding any number of relative dates, and they are accumulated, but only towards past. Relative date can be combined with absolute date, as long as the same absolute unit is not specified twice (can't say "january february", but "january one month" is one month back from january). (With a couple of small further patches still in my local tree) you can specify time zone for all of the above. BR, Jani. > > 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 >