use start of week not month
This commit is contained in:
@ -9,22 +9,25 @@ module TimelineHelper
|
||||
def max_days
|
||||
@weeks * 7
|
||||
end
|
||||
def start_day
|
||||
Date.today.at_beginning_of_week - 1.week
|
||||
end
|
||||
# number of days from start of month to start of stay
|
||||
def started_days(member)
|
||||
return 0 unless member.arriving
|
||||
return 0 if member.arriving < Date.today.at_beginning_of_month
|
||||
distance = (member.arriving - Date.today.at_beginning_of_month).to_i
|
||||
return 0 if member.arriving < start_day
|
||||
distance = (member.arriving - start_day).to_i
|
||||
distance > max_days ? max_days : distance
|
||||
end
|
||||
def left_max
|
||||
Date.today.at_beginning_of_month + 3.months
|
||||
start_day + 3.months
|
||||
end
|
||||
|
||||
# amount of days of the stay, maxed at the number fo weeks shown
|
||||
def stay_days(member)
|
||||
return 0 unless member.leaving
|
||||
start = member.arriving
|
||||
start = Date.today.at_beginning_of_month if member.arriving < Date.today.at_beginning_of_month
|
||||
start = start_day if member.arriving < start_day
|
||||
distance = ( member.leaving - start ).to_i
|
||||
max = max_days - started_days(member)
|
||||
distance > max ? max : distance
|
||||
@ -32,7 +35,7 @@ module TimelineHelper
|
||||
|
||||
# weekly occupany, hash containing weeks to number of volunteer mapping
|
||||
def weekly
|
||||
month_start = Date.today.at_beginning_of_month
|
||||
month_start = start_day
|
||||
( 0 ... @weeks ).collect do |week|
|
||||
amount = -1
|
||||
start_week = month_start + week.weeks
|
||||
|
Reference in New Issue
Block a user