I believe you’re looking for temporal expressions.
I believe that I am, too. I came across Runt and that lead me to the
article written by Martin Fowler about Temporal Expressions.
Would be nice if you could include my original message the next time, it’s easier for me to remember what I posted instead of having to search my mail for the original reply
Definitely a step in the right direction. However, I still can’t wrap
my mind around how to create a form that I can use to create these
temporal expressions,
It all depends on the complexity of your recurring events really. I’d suggest starting off by building a form that incorporates the schedule parameters you want to convert into a Runt expression. You could use something like what Google Calendar does, which is pretty basic, or you can go full out complex with multiple combined expressions etc.
Your biggest challenge after that will be to convert the parameters that come into your controller into a Runt expression. I’d suggest writing a dedicated class for that, something like
class RuntExpressionBuilder
def initialize(params)
# code goes here
end
end
Runt has some nice docs on how to create expressions at http://runt.rubyforge.org/doc/files/doc/tutorial_te_rdoc.html
Not much I can do to help you here, you’ll just need to bite the bullet and write something that works for you based on what the docs provide.
then how to convert the temporal expressions
into a schedule layout.
Once you have your expression, you can ask it to give you all the dates in a certain range that comply with your expression:
require ‘runt’
require ‘date’
include Runt
mon_wed_fri = DIWeek.new(Mon) | DIWeek.new(Wed) | DIWeek.new(Fri)
schedule = mon_wed_fri.dates(DateRange.new(PDate.day(2011,7,7),PDate.day(2011,7,20)))
puts schedule
2011-07-08T00:00:00+00:00
2011-07-11T00:00:00+00:00
2011-07-13T00:00:00+00:00
2011-07-15T00:00:00+00:00
2011-07-18T00:00:00+00:00
2011-07-20T00:00:00+00:00
It’ll be up to you to determine how you want to display that schedule to the user of course. You can generate some kind of calendar like has been suggested or keep it plain and simple with a list. It all depends on your application I guess.
Best regards
Peter De Berdt