[Rails] Re: Using timezone javascript to set Time.zone
Thanks for the replies.
The solution I've come up with for now is to use the javascript that
determines the timezone to store the timezone in a cookie using the
onload event. I then read it back out of the cookie in Rails with a
before_filter on application_controller.rb.
I'm not convinced its the best solution as obviously not everyone
turns cookies on, hmmm...
detect_timezone.js :
jstz.set_timezone_in_cookie = function () {
var tz_info = jstz.determine_timezone();
document.cookie="timezone =" + tz_info.timezone.olson_tz;
}
application_controller.rb :
before_filter :set_timezone
def set_timezone
Time.zone = request.cookies["timezone"]
end
Any thoughts? Many thanks.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home