TL;DR - https://gist.github.com/jwoertink/5035116
I have a datetime picker in my app
(http://trentrichardson.com/examples/timepicker/). When someone clicks
in a text_field, the picker pops up and displays the calendar with the
time, and timezone.
I have the timezones for that select box populated like this
var timezones = function() {
zones = [
<% ActiveSupport::TimeZone.all.sort_by(&:name).each_with_index do
|timezone, index| %>
{ value: '<%= timezone.formatted_offset(false) %>', label: "<%=
timezone.name %>" },
<% end %>
]
return zones;
};
The issue I'm running into is that when someone selects "Pacific Time
(US & Canada)" the value of that option is "-0800". If the date they
selected is after March 10th (2013), then the "Pacific Time (US &
Canada)" time zone is actually "-0700". So what happens is they save the
record as 2013-03-15 08:00 pm -0800, then it gets stored in the DB as
Fri, 15 Mar 2013 21:00:00 PDT -07:00.
Now, if they save the date as before March 10th (2013), then it saves
the correct time.
So, is there some method in rails where I can pass a date, and it will
return the proper offset for any time zone with DST into consideration?
Thanks,
~Jeremy
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment