Skip to content
Simple Rails 3.1+ gem for better timezone detection
Branch: master
Clone or download
Latest commit 0a1e2bb Mar 19, 2013
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
vendor/assets/javascripts
.gitignore first commit Sep 4, 2011
.rbenv-gemsets first commit Sep 4, 2011
Gemfile
Gemfile.lock adding railties dependency no assets actualy work Sep 4, 2011
Rakefile first commit Sep 4, 2011
detect_timezone_rails.gemspec Allows Rails 4 apps to use this gem Mar 19, 2013
readme.md Documentation update for the new 'format' option Sep 2, 2012

readme.md

Detect Timezone Rails

This is a simple gem which bundles jstimezonedetect and my own jquery plugin for it

NOTE: There is no dependency on jquery, so you can also use this to simply bundle jstimezonedetect.

How to use it

In your Gemfile:

gem 'detect_timezone_rails'

Require detect_timezone and jquery.detect_timezone in your Javascript manifest (i.e. application.js)

//= require detect_timezone
//= require jquery.detect_timezone

Then some where else, wire it up using the plugin (remember to require jquery as well for the plugin)

$(document).ready(function(){
	$('#your_input_id').set_timezone(); 
});

If you are using the standard rails form helpers to generate a timezone select, you may pass the format option when calling set_timezone, to return only the city name:

$(document).ready(function(){
    $('#your_input_id').set_timezone({format: 'city'});
})

Disclaimers

Requires Rails 3.1+.

License

Provided under the Do Whatever You Want With This Code License.

You can’t perform that action at this time.