Bug fix: when by_month and by_week accept a Date, must convert date.to_time first.

The reason is this is that Date.end_of_week and Date.end_of_month under some conditions yield the *beginning* of the last day, rather than the end, so the query misses the last day of the period.

Probably this fix is required everywhere Date type is used.