Currently, the application time zone is UTC. All the time related information should be displayed in
This is achieved by using an around filter(TimeZoneFilter) in the base controller which wraps all the actions inside Time.use_zone(user_time_zone) block. So, the application time zone is changed to the parameter of Time.use_time_zone inside all the actions.
The logic to find the time zone from browser offset can be found in lib/time_helper.rb. Rails default TimeZone find does not search by summer and winter offsets, it searches by utc_offset and returns the first result that matches any one of the offsets. As more than one place can have same utc_offset, we would miss the daylight savings this way.(Ex- Bogota and Eastern Standard(EST) zones have same utc_offset. We always get Bogota which has no day light savings. But we might be in EST which uses DST). So, we are matching both summer and winter offsets.
Points to consider while dealing with time information -
1. Use Time.zone.* not Time.* - Most of the scenarios we need to deal with times in the current time zone not in the system time zone on which app is running. So, we should use Time.zone.now, Time.zone.parse and time_obj.in_time_zone(Time.zone) when we are dealing with time information.
2. Use Time.use_zone when we need to operate in other time zones than the current system. This sets back the system time zone when exception occurs. Otherwise we should always remember to set the system's time zone back to default.
3. When we add a new place from where some one can login, we should make sure that his time zone is getting updated. So, for now, after creating the user session we can call “set_user_time_zone(current_user)” in the controller. This method is defined in base_controller.rb