# Runt Recurring events

**URL:** <https://www.ruby-forum.com/t/runt-recurring-events/152998>\
**Category:** Rails\
**Created:** [November 11, 2008, 12:21am UTC](https://www.ruby-forum.com/t/runt-recurring-events/152998 "2008-11-11T00:21:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 11, 2008, 12:21am UTC](https://www.ruby-forum.com/t/runt-recurring-events/152998/1 "2008-11-11T00:21:11Z")

</div>

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 = Runt::DIWeek.new(4)

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 = Runt::DIMonth.new(First,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

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 11, 2008, 2:34am UTC](https://www.ruby-forum.com/t/runt-recurring-events/152998/2 "2008-11-11T02:34:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 25, 2008, 8:35pm UTC](https://www.ruby-forum.com/t/runt-recurring-events/152998/3 "2008-11-25T20:35:10Z")

</div>

hi David,

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

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 25, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/runt-recurring-events/152998/4 "2008-11-25T20:40:26Z")

</div>

ok… basing myself on what I could see on

> **[Gem and I: Runt](https://www.slideshare.net/cglee/gem-and-i-runt-presentation)**
>
> Runt Ruby gem for building temporal expressions squeejee Chris Lee Gettin...

here’s what I would do

Runt::EveryTE.new(Time.now,2,Runt::DPrecision.Precision.week)

which would be every two weeks starting today.

Jean-Marc

> **[M2i3 - Connecter les besoins aux solutions](https://m2i3.com/)**
>
> Nous sommes M2i3, des "socials-geeks" passionnés par le web, l'infonuagique et les logiciels. Nous vous présentons IncognitoDesk Après des an ...
