I understand the basics of timezone support:

http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/

Essentially, I just have to do this:

# controllers/application.rb
before_filter :set_time_zone

def set_time_zone
  Time.zone = @current_user.time_zone if @current_user
end

That will set the timezone to the particular user's stored timezone and
all will be well in the world.

The part I am trying to figure out is how to "guess" the user's timezone
in the first place. The application I am working on calls for the user
registration to be dead simple and not include a huge timezone selection
box.

I can think of two methods for guessing timezone:

1) Based on IP Address of client
2) Based on a cookie stored on their computer with their current offset

I would probably go with #2 (i.e store a cookie with their current
offset from utc and then use that to fetch the first timezone which
matches the offset)

Yes this would be inaccurate in that the wrong timezone may be selected
but I would always have a select box in their settings area that would
allow them to correct it and it would "get the job done".

Thoughts? Is there a better way?
-- 
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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to