终于让它工作了!不是很漂亮(我希望有一个更干净的解决方案),但是这样做有效:
>> Payment.all(:conditions =>
["Date((payments.created_at at time zone 'UTC')
at time zone :timezone) >= :start_date and
Date((payments.created_at at time zone 'UTC')
at time zone :timezone) <= :end_date",
:start_date => start_date, :end_date => end_date,
:timezone => 'Asia/Katmandu'])
不过,我并不真正喜欢这样做:
Date((payments.created_at at time zone 'UTC') at time zone 'Asia/Katmandu')
为何postgresql不允许您这样做?
Date(payments.created_at at 'Asia/Katmandu')