Fix bug.
This commit is contained in:
parent
48c4948946
commit
a6e9c31222
|
@ -119,6 +119,7 @@ class PHire
|
|||
if date_only
|
||||
@recurring_events = @recurring_events.where(:date.ne=>nil)
|
||||
end
|
||||
start_date_utc_mjd = start_date.to_datetime.utc.mjd
|
||||
@recurring_events.each do |re|
|
||||
datet = re.date
|
||||
interval = 1.send(re.recurring_interval) rescue 0
|
||||
|
@ -133,10 +134,16 @@ class PHire
|
|||
period_str = nil
|
||||
if re.recurring_interval == "week"
|
||||
period_str = 'week'
|
||||
add_interval = ((start_date - @start_date - 1.day).to_i / 7.day)
|
||||
add_interval = (start_date_utc_mjd - @start_date.utc.mjd)
|
||||
days = 7.day
|
||||
if add_interval < 0
|
||||
add_interval = -(-add_interval / days)
|
||||
else
|
||||
add_interval = add_interval / days
|
||||
end
|
||||
else
|
||||
period_str = 'month'
|
||||
add_interval = ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month) - 1)
|
||||
add_interval = ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month))
|
||||
end
|
||||
add_interval = 0 if add_interval < 0
|
||||
add_interval = add_interval.send(period_str)
|
||||
|
|
Loading…
Reference in New Issue