fix start of timeline
This commit is contained in:
@ -9,6 +9,7 @@ module TimelineHelper
|
||||
def max_days
|
||||
@weeks * 7
|
||||
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
|
||||
@ -18,11 +19,13 @@ module TimelineHelper
|
||||
def left_max
|
||||
Date.today.at_beginning_of_month + 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
|
||||
distance = ( member.leaving - member.arriving ).to_i
|
||||
distance = ( member.leaving - start ).to_i
|
||||
max = max_days - started_days(member)
|
||||
distance > max ? max : distance
|
||||
end
|
||||
|
Reference in New Issue
Block a user