Hey Tom,

Not sure if you have seen DateBocks (http://datebocks.inimit.com), it
does much of the same in JavaScript.

Very cool plugin indeed, if I do say so myself ;)

-NSHB

On 9/7/06, Tom Werner <tom / helmetstohardhats.org> wrote:
> Mat Schaffer wrote:
> > On 9/7/06, Tom Werner <tom / helmetstohardhats.org> wrote:
> >> Chronic is a natural language date/time parser written in pure Ruby.
> >> See below for the wide variety of formats Chronic will parse.
> >
> > This is really really awesome.  How did you implement stuff like "the
> > 3rd tuesday in January"?  I've been wrestling with that concept for
> > awhile not in a OS X Dashboard clock I made.
> > -Mat
>
> Chronic uses a compiler approach, so the date is parsed, tokenized, and
> then run through a list of possible matches. The first matching rule
> fires off a handler that knows how to deal with that pattern. To handle
> things like "3rd tuesday in january", it goes something like this:
>
> 3rd [ordinal-3]
> tuesday [repeater-dayname-tuesday]
> in [pointer-future]
> january [repeater-monthname-january]
>
> Which matches a pattern that knows to look for the next future January,
> and beginning with the start of that month, look for the next future
> Tuesday three times. There are classes that represent each of the
> possible repeaters (there a lot of them!), and know everything about how
> to find the next, previous, or this span, and to do offsets. Examine the
> source code if you're really interested, it shouldn't be too hard to grok.
>
> Tom
>
> --
> Tom Werner
> Helmets to Hardhats
> Software Developer
> tom / helmetstohardhats.org
> www.helmetstohardhats.org
>
>
>


-- 
Nathaniel Steven Henry Brown

Open Source Insight - http://nshb.net
Open Source Development - http://inimit.com
Open Source Training  - http://osevents.com