I have some news events that are stored in a database via a postgresql datetime column. However, I would like to run a query on the time of day the event happened. Something like
Event.where("occurred_at < '11:00'")
which you can do if this was a postgresql time column.
To add an additional wrinkle, I have my Rails time zone set to Eastern time for the whole application
config.time_zone = 'Eastern Time (US & Canada)'
So if you were to try to extract the database time somehow, that time would be in UTC, so for during half the year the time comparison would be off by 1 hour (because of daylight savings).
The only thing I can think of is to maintain a separate database column of 'time' type.
Edit and clarification
The tricky part of this question is that the UTC offset changes during half the year because of daylight savings. Time.zone.parse("2013-01-01 10:00") gives Jan 1, 2013 10:00 EST -05:00 (i.e. 15:00 UTC) while six months later Time.zone.parse("2013-07-01 10:00") gives Jul 1, 2013 10:00 EDT -04:00 (i.e. 14:00 UTC). So you cannot just query the time without knowing the date as well.