データベースがUTCである間、レポートをCSTで表示したいと思います。これを機能させるには、時間列でグループ化し、dbにタイムゾーン変換を実行させる必要があります。
これは私の開発postgresqlボックスで機能します:
offset = -5
result = ActiveRecord::Base.connection.execute("select date(srl.created_at AT TIME
ZONE '#{offset.to_s}') AS date, count(*) from server_request_logs srl where
srl.created_at between '#{@from.to_s(:db)}' and '#{@to.to_s(:db)}' group by
date(srl.created_at AT TIME ZONE '#{offset.to_s}')")
herokuでは次のエラーが発生します:
ActiveRecord::StatementInvalid: PGError: ERROR: time zone "-5" not recognized
また、「America / Winnipeg」のようなTZInfo名や、http: //www.postgresql.org/docs/7.2/static/timezones.htmlの「CST」のようなサポートされているタイムゾーンでは機能しません。
誰かがこれを機能させることができましたか?