Forum: Ruby on Rails Runt Recurring events

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2008-11-11 00:21
(Received via mailing list)
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
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2008-11-11 02:34
(Received via mailing list)
I guess my question can be summed up as: can you create a recurring
event for every other week using the Runt class?
3d02b4f32fa6f82ed55b408e471bae55?d=identicon&s=25 Jean-Marc (M2i3.com) (Guest)
on 2008-11-25 20:35
(Received via mailing list)
hi David,

"every other week" has to have a starting point to be possible to
calculate.
3d02b4f32fa6f82ed55b408e471bae55?d=identicon&s=25 Jean-Marc (M2i3.com) (Guest)
on 2008-11-25 20:40
(Received via mailing list)
ok.... basing myself on what I could see on
http://www.slideshare.net/cglee/gem-and-i-runt-presentation/

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
http://m2i3.com
This topic is locked and can not be replied to.