I'm dealing with dates and times in Rails and Postgres and running into this issue:
The database is in UTC.
The user sets a time-zone of choice in the Rails app, but it's only to be used when getting the users local time for comparing times.
User stores a time, say March 17, 2012, 7pm. I don't want timezone conversions or the timezone to be stored. I just want that date and time saved. That way if the user changed their time zone, It would still show March 17, 2012, 7pm.
I only use the users specified time zone to get records 'before' or 'after' the current time in the users local time zone.
I'm currently using 'timestamp without time zone' but when I retrieve the records, rails (?) converts them to the time zone in the app, which I don't want.
Appointment.first.time => Fri, 02 Mar 2012 19:00:00 UTC +00:00
Because the records in the database seem to come out as UTC, my hack is to take the current time, remove the time zone with 'Date.strptime(str, "%m/%d/%Y")' and then do my query with that:
.where("time >= ?", date_start)
It seems like there must be an easier way to just ignore time zones all around. Any ideas?