Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: marcus-sup@bar-coded.net (Marcus Williams)
Subject: [sup-talk] [PATCH] Natural language date searches
Date: Fri, 09 Nov 2007 20:29:58 +0000	[thread overview]
Message-ID: <1194639409-sup-6180@tomsk> (raw)
In-Reply-To: <1194633682-sup-962@south>

On 9.11.2007, William Morgan wrote:
> Modified to skip parsing if Chronic isn't available, and applied.
> Thanks!
> 
> Also made it accept one-word Chronic tokens without parentheses,
> although "after:yesterday" means "after yesterday noon", which maybe is
> not so useful...

I think I may have worked out how to fix that - change the parse
method to be:

realdate = Chronic.parse(datestr, :guess => false).begin

If guess is set to false it looks like Chronic always returns a span
and you can just select the beginning of the span.  At the moment I'm
pretty sure you always want the beginning of the span in search
situations. Certainly makes the single tokens more usable:

irb(main):003:0> Chronic.parse("november", :guess => false).begin
=> Thu Nov 01 00:00:00 +0000 2007
irb(main):004:0> Chronic.parse("monday", :guess => false).begin
=> Mon Nov 12 00:00:00 +0000 2007
irb(main):005:0> Chronic.parse("24 hours ago", :guess => false).begin
=> Thu Nov 08 20:24:14 +0000 2007
irb(main):006:0> Chronic.parse("sunday", :guess => false).begin
=> Sun Nov 11 00:00:00 +0000 2007
irb(main):008:0> Chronic.parse("last sunday", :guess => false).begin
=> Sun Nov 04 00:00:00 +0000 2007
irb(main):010:0> Chronic.parse("first monday of november", :guess => false).begin
=> Mon Nov 05 00:00:00 +0000 2007

Marcus


  reply	other threads:[~2007-11-09 20:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26 22:10 Marcus Williams
2007-10-27 21:10 ` Marcus Williams
2007-11-09 18:46   ` William Morgan
2007-11-09 20:29     ` Marcus Williams [this message]
2007-11-09 20:44       ` Marcus Williams
2007-11-09 21:20         ` Marcus Williams
2007-11-12 18:01           ` William Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1194639409-sup-6180@tomsk \
    --to=marcus-sup@bar-coded.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox