I'm setting the timezone for the users in my applicationcontroller
around_filter :user_time_zone, :if => :current_user
def user_time_zone(&block)
Time.use_zone(current_user.time_zone, &block)
end
And the server stores the times as UTC, and created_at fields get updated accordingly to the user timezone. However, when I'm using a postgres timerange, the time in the range displays as UTC:
#<TimeEntry:0x007fb7c8701a20
id: "5556cb4f-862f-4f7d-bb30-743578ba5741",
time: 2016-05-03 21:02:28 UTC..2016-05-04 02:02:33 UTC,
created_at: Tue, 03 May 2016 16:32:33 VET -04:30,
updated_at: Tue, 03 May 2016 16:32:52 VET -04:30>
I'm building the timerange like this:
def self.build_timerange(start_time_ms, end_time_ms)
start_time = Time.zone.at(start_time_ms.to_f / 1000)
end_time = Time.zone.at(end_time_ms.to_f / 1000)
start_time..end_time
end
I need to get them from the browser as ms.
I'd like the time
range to update to the current request timezone (the user timezone), is it possible?