From: mlipper@... Date: 2004-03-18T23:46:33+09:00 Subject: Re: Thinking about a date-matching algorithm... Hey Hal, I've recently started a project named Runt(Ruby Temporal Expressions) that allows one to specify patterns of date recurrence using single set-like expressions. It's based on several excellent patterns and ideas by Martin Fowler. I originally wrote this in Java( see http://chronicJ.org ), but recently developed an allergy to curly braces. The project is just getting started and I'm still learning Ruby, but enough's in place so you can build relatively complex expressions. See: http://runt.rubyforge.org for a general introduction and here http://runt.rubyforge.org/doc/files/doc/tutorial_te_rdoc.html for a tutorial introduction. I'd be very interested in your, and everyone else's feedback. To answer (some) of your example questions: "Every Monday" expr = DayInWeekTE.new(Monday) #Monday expr.include?(Date.new(2004,1,12)) #=> true #Tuesday expr1.include?(Date.new(2004,1,13)) #=> false "Every 2nd and 4th Friday." expr2 = UnionTE.new \ .add(DayInMonthTE.new(Second,Friday)) \ .add(DayInMonthTE.new(Fourth,Friday)) If you do decide to try Runt, let me know if you have any questions or problems. toodles, --Matt -----Original Message----- From: Hal Fulton [mailto:hal9000@hypermetrics.com] Sent: Thursday, March 18, 2004 1:40 AM To: ruby-talk@ruby-lang.org Subject: Thinking about a date-matching algorithm... I did a little swapping of ideas with dblack on this. Now I'm opening discussion to anyone interested. I'm writing a little to-do manager (chiefly for my own use). I want to allow recurring tasks. Some of these will be simple, like "Every Monday." Others will be more complex, like "Every 2nd and 4th Friday." Some might not even be based on weeks or months at all, but might be like: "Every ten days, no matter what." There'd also be an option to give advance warning (N days) on each event. So the question becomes: Given a date (typically "today") and a list of recurring tasks, how do I determine which ones need to be displayed? Cheers, Hal