here''s one way - not a one-liner, but not too complex:
start_date = DateTime.parse(''2008-01-01'')
end_date = DateTime.parse(''2008-04-01'')
range = (start_date..end_date)
wday = 1
use_this = false
every_other = []
range.each do |date|
every_other << date if date.wday == wday && use_this
use_this = !use_this
end
puts every_other.inspect
On Nov 11, 6:16 am, David <dly...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have the code for computing a weekly event:
>
> (start_date..end_date).select{|d| d.wday == wday}
>
> but I am wondering if anyone has any ideas for using this to figure
> out a recurring event for every other week. Is it possible to somehow
> specify every other within the .select method? Any other
> implementation ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---