diff --git a/app/models/p_hire.rb b/app/models/p_hire.rb index 087ea2e..bab054f 100644 --- a/app/models/p_hire.rb +++ b/app/models/p_hire.rb @@ -110,6 +110,13 @@ class PHire recurring_end_date = re.recurring_end_date new_end_date = [recurring_end_date,end_date].min @end_date = re.end_time + if @start_date < start_date + if re.recurring_interval == "week" + @start_date += (start_date - @start_date).to_i / 7) * interval + else + @start_date += ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month) - 1) * interval + end + end while @start_date <= new_end_date do if unavailable && (unavailable_start_date <= @start_date) && (unavailable_end_date >= @end_date) && !((@start_date.strftime("%w").to_i .. @end_date.strftime("%w").to_i).to_a & unavailable_weekdays).empty? startt = DateTime.parse(@start_date.strftime("%Y-%m-%d " + unavailable_start_time + Time.zone.to_s))