I’m using the JQuery full calendar in one of my rails applications,
however I’ve spotted (what I believe to be a bug) which is really
bugging me as I can’t fix it.
Lets say my configured “END_TIME” is 31st December 2011 00:00:00 and I
create a daily event from 1st December 2011 16:20 - 17:20, to the
“END_TIME” the events are created from the 1st to the 29th. If I then
for example create a weekly event, occurring every 1 weeks from 1st
December 2011 16:20 - 17:20 to 31 to the “END_TIME” It stops on the 22nd
of December 2011 (1 week before its meant to)
It looks to me like the way events are created, its cutting short by 1x
the frequency but I’m unsure how to correctly fix this.
The code from the model is below.
##model##
def after_create
create_events_until
end
def create_events_until
st = starttime
et = endtime
p = r_period(period)
nst, net = st, et
while frequency.send§.from_now(st) <= (END_TIME)
self.events.create(:title => title, :description => description,
:all_day => all_day, :starttime => nst, :endtime => net, :user_id =>
user_id,
:remind_at => remind_at, :remind_setting => remind_setting,
:remind_value => remind_value, :set_reminder => set_reminder,
:calendar_id => calendar_id, :resource_ids => resource_ids)
nst = st = frequency.send§.from_now(st)
net = et = frequency.send§.from_now(et)
if period.downcase == ‘monthly’ or period.downcase == ‘yearly’
begin
nst =
DateTime.parse("#{starttime.hour}:#{starttime.min}:#{starttime.sec},
#{starttime.day}-#{st.month}-#{st.year}")
net =
DateTime.parse("#{endtime.hour}:#{endtime.min}:#{endtime.sec},
#{endtime.day}-#{et.month}-#{et.year}")
rescue
nst = net = nil
end
end
end
end
def r_period(period)
case period
when ‘Daily’
p = ‘days’
when “Weekly”
p = ‘weeks’
when “Monthly”
p = ‘months’
when “Yearly”
p = ‘years’
end
return p
end
##end model##