fix error

This commit is contained in:
chiu 2020-05-19 23:17:25 +08:00
parent 6c3cf31b03
commit 23c6753646
1 changed files with 11 additions and 9 deletions

View File

@ -95,12 +95,14 @@ class Property
case interval
when 'week'
d_step = 1.week
when 'day'
d_step = 1.day
when 'month'
d_step = 1.month
else
d_step = 0
end
bookings.each do |booking|
stime_tp = stime
etime_tp = etime
b_interval = booking.recurring_interval
if b_interval == 'month'
b_sdata = booking.start_time.day*10000 + booking.start_time.hour*100 + booking.start_time.minute
@ -111,18 +113,18 @@ class Property
end
while true
if b_interval == 'month'
sdata = stime.day*10000 + stime.hour*100 + stime.minute
edata = etime.day*10000 + etime.hour*100 + etime.minute
sdata = stime_tp.day*10000 + stime_tp.hour*100 + stime_tp.minute
edata = etime_tp.day*10000 + etime_tp.hour*100 + etime_tp.minute
elsif b_interval == 'week'
sdata = stime.wday*10000 + stime.hour*100 + stime.minute
edata = etime.wday*10000 + etime.hour*100 + etime.minute
sdata = stime_tp.wday*10000 + stime_tp.hour*100 + stime_tp.minute
edata = etime_tp.wday*10000 + etime_tp.hour*100 + etime_tp.minute
end
if (b_sdata <= sdata && b_edata >= sdata) || (b_sdata >= sdata && b_edata <= edata) || (b_sdata <= edata && b_edata >= edata)
available = false
end
stime = stime + d_step
etime = etime + d_step
break if recurring_end_date.nil? || recurring_end_date < stime
stime_tp = stime_tp + d_step
etime_tp = etime_tp + d_step
break if recurring_end_date.nil? || recurring_end_date < stime_tp
end
break if available == false
end