Closed drjakob closed 7 years ago
Okay, I think the problem is caused by lines 62 and 65 in the TextComponent model. They are checking wether the DiaryEntry moment is <= than the to_day
and => the from_day
, respectively.
if from_day
result &= ((report.start_date + from_day.days) <= diary_entry.moment)
end
if to_day
result &= (diary_entry.moment <= (report.start_date + to_day.days))
end
However, they are comparing the DiaryEntry moment, which is a DateTime
object (or more precisely a ActiveSupport:TimeWithZone
object) with the upper or lower boundaries of the day span which are both simple Date
objects.
Debugging the DiaryEntry moment and the boundaries returns the following:
diary_entry.moment => Sun, 03 Sep 2017 06:05:07 CEST +02:00
report.start_date + from_day.days => Sun, 03 Sep 2017
report.start_date + to_day.days => Sun, 03 Sep 2017
This way, the second condition for the to day won’t be met. Converting the DiaryEntry moment to a Date
object first should solve this. I’m not totally sure if this is safe to change, though, and would be glad if @roschaefer could take a look at it.
if from_day
result &= ((report.start_date + from_day.days) <= diary_entry.moment.to_date)
end
if to_day
result &= (diary_entry.moment.to_date <= (report.start_date + to_day.days))
end
Please check: Could it be, that from day 1 to day one is not working properly in tc timespan?