Runt Recurring events

I am planning on using Runt to calculate recurring events. I
calculate a Runt object in the view and use it to see if it includes a
certain date, which is populates from the database, and display the
info for that date if it is included. I have recurring events for
every week, which was pretty easy to set up. I can just say:

r =

For a recurring event every Thursday, and then do r.include(some_date)
to see if it falls on a Thursday. The
question I have is for developing recurring events for other time
limits, such as twice a month/every other week, once a month, once
every other month, once every six months. To create Runt expressions
for every other week, you can create an expression using the day name
with respect to its order in the month. So, for example, you can say
I want a recurring event for the first Tuesday of every month and that
would look like this:

r =,Tuesday)

You are allowed to use these orderings: (first|second|third|fourth|
last|second_to_last). So this will allow me to do the expressions
every other week and once a month. But my question is, does anyone
have a fast clean way of figuring out the ordering of a day within the
month given its date. So, for example, if I have the date November
20th, 2008 and I want to figure out if that is the first, second,
third, or fourth Thursday of the month how would I do this?

I guess the easiest way is to write a function that takes the day
number and divides the date by 7? If its less than or equal to one
then it is the first day of the month, if it has a remainder of one
then it is the second and so on… Just looking for some feedback on
this idea and any other ideas. Maybe there is some way to do it with
the Runt class? Thanks, Dave

I guess my question can be summed up as: can you create a recurring
event for every other week using the Runt class?

hi David,

“every other week” has to have a starting point to be possible to

ok… basing myself on what I could see on

here’s what I would do,2,Runt::DPrecision.Precision.week)

which would be every two weeks starting today.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs