Mat Schaffer
9/8/2006 5:36:00 PM
On 9/7/06, Tom Werner <tom@helmetstohardhats.org> wrote:
> 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.
Okay, so you use an itertive approach. I made this clock for OS X's
dashboard that does it using a formula borrowed from another widget.
No-one I've showed it to has been able to figure out just what it
does. If you're interested, I suppose it'd be better suited to an
offline discussion. Feel free to email me.
-Mat