Time Zone Mixing (1 hour)

Time.use_zone('Pacific Time (US & Canada)') do p Time.zone.now end 

I get the following: => Sun, 14 Apr 2013 20:30:53 PDT -07:00

However, when I do the Rails Time Zone Select ..., it clearly says -8:00 . Why is it -7 in one area and -8 in another?

In other cases, time zones, such as Hawaii , that -10:00 do not get an hour offset.

I suppose this has something to do with DST, but I'm more curious if that means it works correctly or incorrectly, and I need to do something else.

Ultimately, I use this in a datepicker, and it is very strange to me that when I use Time.zone.parse (along with my time zone around the filter), it compensates everything for 1 hour.

thanks

Edit

Here is the same problem I encountered with another piece of code

 2.0.0-p0 :006 > 2.0.0-p0 :006 > u.meetups.in_future.first.meetup_time Meetup Load (0.4ms) SELECT `meetups`.* FROM `meetups` WHERE `meetups`.`user_id` = 1 AND (meetup_time >= '2013-04-23 04:46:48') ORDER BY meetup_time ASC LIMIT 1 => Tue, 23 Apr 2013 05:43:00 UTC 00:00 2.0.0-p0 :007 > 

Note the inconsistency between the result and the where clause.

Edit

It seems that it works for CST correctly, but PST is disabled for ~ 1 hour ?? I feel that this is the same problem, I just miss a piece of the puzzle.

+4
source share
1 answer

The output is correct. Pacific Daylight Time has an offset of -7, while Pacific Standard Time has an offset of -8. I assume that the “Rails Time Zone Select” (whatever it is) shows only the “standard” offsets, not the current ones. This is a common occurrence in time zone collectors.

Hawaii does not have daylight saving time of any type, so it refers to your second point.

In the third paragraph, I would have to learn more about your database platform in order to answer why the values ​​are converted to UTC. Given that these are events, I would say that they should be in UTC. They can also be in the time zone of the “meeting” location, but only if the offset from UTC is also saved. But should never be in the time zone of the server.

At your fourth point, it’s hard to say what you mean without any details. Expand if you think necessary.

+2
source

All Articles