├── .gitignore ├── .rbenv-gemsets ├── Gemfile ├── Gemfile.lock ├── Rakefile ├── detect_timezone_rails.gemspec ├── lib ├── detect_timezone_rails.rb └── detect_timezone_rails │ └── version.rb ├── readme.md └── vendor └── assets └── javascripts ├── detect_timezone.js └── jquery.detect_timezone.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | pkg/* 4 | -------------------------------------------------------------------------------- /.rbenv-gemsets: -------------------------------------------------------------------------------- 1 | detect_timezone_rails global 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | # Specify your gem's dependencies in detect_timezone_rails.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | detect_timezone_rails (0.0.1) 5 | railties (~> 3.1) 6 | 7 | GEM 8 | remote: http://rubygems.org/ 9 | specs: 10 | actionpack (3.1.0) 11 | activemodel (= 3.1.0) 12 | activesupport (= 3.1.0) 13 | builder (~> 3.0.0) 14 | erubis (~> 2.7.0) 15 | i18n (~> 0.6) 16 | rack (~> 1.3.2) 17 | rack-cache (~> 1.0.3) 18 | rack-mount (~> 0.8.2) 19 | rack-test (~> 0.6.1) 20 | sprockets (~> 2.0.0) 21 | activemodel (3.1.0) 22 | activesupport (= 3.1.0) 23 | bcrypt-ruby (~> 3.0.0) 24 | builder (~> 3.0.0) 25 | i18n (~> 0.6) 26 | activesupport (3.1.0) 27 | multi_json (~> 1.0) 28 | bcrypt-ruby (3.0.0) 29 | builder (3.0.0) 30 | erubis (2.7.0) 31 | hike (1.2.1) 32 | i18n (0.6.0) 33 | multi_json (1.0.3) 34 | rack (1.3.2) 35 | rack-cache (1.0.3) 36 | rack (>= 0.4) 37 | rack-mount (0.8.3) 38 | rack (>= 1.0.0) 39 | rack-ssl (1.3.2) 40 | rack 41 | rack-test (0.6.1) 42 | rack (>= 1.0) 43 | railties (3.1.0) 44 | actionpack (= 3.1.0) 45 | activesupport (= 3.1.0) 46 | rack-ssl (~> 1.3.2) 47 | rake (>= 0.8.7) 48 | rdoc (~> 3.4) 49 | thor (~> 0.14.6) 50 | rake (0.9.2) 51 | rdoc (3.9.4) 52 | sprockets (2.0.0) 53 | hike (~> 1.2) 54 | rack (~> 1.0) 55 | tilt (~> 1.1, != 1.3.0) 56 | thor (0.14.6) 57 | tilt (1.3.3) 58 | 59 | PLATFORMS 60 | ruby 61 | 62 | DEPENDENCIES 63 | detect_timezone_rails! 64 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /detect_timezone_rails.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "detect_timezone_rails/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "detect_timezone_rails" 7 | s.version = DetectTimezoneRails::VERSION 8 | s.authors = ["Scott Watermasysk"] 9 | s.email = ["scottwater@gmail.com"] 10 | s.homepage = "https://rubygems.org/gems/detect_timezone_rails" 11 | s.summary = %q{Simple javascript timezone detection} 12 | s.description = %q{Simple javascript timezone detection} 13 | 14 | s.rubyforge_project = "detect_timezone_rails" 15 | 16 | s.add_dependency "railties", ">= 3.1" 17 | 18 | s.files = `git ls-files`.split("\n") 19 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 20 | s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 21 | s.require_paths = ["lib"] 22 | 23 | # specify any dependencies here; for example: 24 | # s.add_development_dependency "rspec" 25 | # s.add_runtime_dependency "rest-client" 26 | end 27 | -------------------------------------------------------------------------------- /lib/detect_timezone_rails.rb: -------------------------------------------------------------------------------- 1 | require "detect_timezone_rails/version" 2 | 3 | module DetectTimezoneRails 4 | class Engine < Rails::Engine 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/detect_timezone_rails/version.rb: -------------------------------------------------------------------------------- 1 | module DetectTimezoneRails 2 | VERSION = "0.0.5" 3 | end 4 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Detect Timezone Rails 2 | 3 | This is a simple gem which bundles [jstimezonedetect](https://bitbucket.org/pellepim/jstimezonedetect) and my own [jquery plugin](https://github.com/scottwater/jquery.detect_timezone) for it 4 | 5 | _NOTE:_ There is no dependency on jquery, so you can also use this to simply bundle jstimezonedetect. 6 | 7 | ## How to use it 8 | 9 | In your Gemfile: 10 | 11 | gem 'detect_timezone_rails' 12 | 13 | Require detect\_timezone and jquery.detect\_timezone in your Javascript manifest (i.e. application.js) 14 | 15 | //= require detect_timezone 16 | //= require jquery.detect_timezone 17 | 18 | Then some where else, wire it up using the plugin (remember to require jquery as well for the plugin) 19 | 20 | $(document).ready(function(){ 21 | $('#your_input_id').set_timezone(); 22 | }); 23 | 24 | If you are using the standard rails form helpers to generate a timezone select, you may pass the 25 | `format` option when calling `set_timezone`, to return only the city name: 26 | 27 | $(document).ready(function(){ 28 | $('#your_input_id').set_timezone({format: 'city'}); 29 | }) 30 | 31 | ## Disclaimers 32 | 33 | Requires Rails 3.1+. 34 | 35 | ## License 36 | 37 | Provided under the Do Whatever You Want With This Code License. 38 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/detect_timezone.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Original script by Josh Fraser (http://www.onlineaspect.com) 3 | * Continued and maintained by Jon Nylander at https://bitbucket.org/pellepim/jstimezonedetect 4 | * 5 | * Provided under the Do Whatever You Want With This Code License. 6 | */ 7 | /** 8 | * Namespace to hold all the code for timezone detection. 9 | */ 10 | var jstz = {}; 11 | jstz.HEMISPHERE_SOUTH = 'SOUTH'; 12 | jstz.HEMISPHERE_NORTH = 'NORTH'; 13 | jstz.HEMISPHERE_UNKNOWN = 'N/A'; 14 | jstz.olson = {}; 15 | 16 | /** 17 | * A simple object containing information of utc_offset, which olson timezone key to use, 18 | * and if the timezone cares about daylight savings or not. 19 | * 20 | * @constructor 21 | * @param {string} offset - for example '-11:00' 22 | * @param {string} olson_tz - the olson Identifier, such as "America/Denver" 23 | * @param {boolean} uses_dst - flag for whether the time zone somehow cares about daylight savings. 24 | */ 25 | jstz.TimeZone = function (offset, olson_tz, uses_dst) { 26 | this.utc_offset = offset; 27 | this.olson_tz = olson_tz; 28 | this.uses_dst = uses_dst; 29 | }; 30 | 31 | /** 32 | * Prints out the result. 33 | * But before it does that, it calls this.ambiguity_check. 34 | */ 35 | jstz.TimeZone.prototype.display = function () { 36 | this.ambiguity_check(); 37 | var response_text = 'UTC-offset: ' + this.utc_offset + '
'; 38 | response_text += 'Zoneinfo key: ' + this.olson_tz + '
'; 39 | response_text += 'Zone uses DST: ' + (this.uses_dst ? 'yes' : 'no') + '
'; 40 | 41 | return response_text; 42 | }; 43 | 44 | /** 45 | * Checks if a timezone has possible ambiguities. I.e timezones that are similar. 46 | * 47 | * If the preliminary scan determines that we're in America/Denver. We double check 48 | * here that we're really there and not in America/Mazatlan. 49 | * 50 | * This is done by checking known dates for when daylight savings start for different 51 | * timezones. 52 | */ 53 | jstz.TimeZone.prototype.ambiguity_check = function () { 54 | var ambiguity_list, length, i, tz; 55 | ambiguity_list = jstz.olson.ambiguity_list[this.olson_tz]; 56 | 57 | if (typeof (ambiguity_list) === 'undefined') { 58 | return; 59 | } 60 | 61 | length = ambiguity_list.length; 62 | i = 0; 63 | 64 | for (; i < length; i += 1) { 65 | tz = ambiguity_list[i]; 66 | 67 | if (jstz.date_is_dst(jstz.olson.dst_start_dates[tz])) { 68 | this.olson_tz = tz; 69 | return; 70 | } 71 | } 72 | }; 73 | 74 | /** 75 | * Checks whether a given date is in daylight savings time. 76 | * 77 | * If the date supplied is after june, we assume that we're checking 78 | * for southern hemisphere DST. 79 | * 80 | * @param {Date} date 81 | * @returns {boolean} 82 | */ 83 | jstz.date_is_dst = function (date) { 84 | var date_offset, base_offset; 85 | base_offset = ((date.getMonth() > 5 ? jstz.get_june_offset() 86 | : jstz.get_january_offset())); 87 | 88 | date_offset = jstz.get_date_offset(date); 89 | 90 | return (base_offset - date_offset) !== 0; 91 | }; 92 | 93 | /** 94 | * Gets the offset in minutes from UTC for a certain date. 95 | * 96 | * @param date 97 | * @returns {number} 98 | */ 99 | jstz.get_date_offset = function (date) { 100 | return -date.getTimezoneOffset(); 101 | }; 102 | 103 | /** 104 | * This function does some basic calculations to create information about 105 | * the user's timezone. 106 | * 107 | * Returns a primitive object on the format 108 | * {'utc_offset' : -9, 'dst': 1, hemisphere' : 'north'} 109 | * where dst is 1 if the region uses daylight savings. 110 | * 111 | * @returns {Object} 112 | */ 113 | jstz.get_timezone_info = function () { 114 | var january_offset, june_offset, diff; 115 | january_offset = jstz.get_january_offset(); 116 | june_offset = jstz.get_june_offset(); 117 | diff = january_offset - june_offset; 118 | 119 | if (diff < 0) { 120 | return { 121 | 'utc_offset' : january_offset, 122 | 'dst': 1, 123 | 'hemisphere' : jstz.HEMISPHERE_NORTH 124 | }; 125 | } else if (diff > 0) { 126 | return { 127 | 'utc_offset' : june_offset, 128 | 'dst' : 1, 129 | 'hemisphere' : jstz.HEMISPHERE_SOUTH 130 | }; 131 | } 132 | 133 | return { 134 | 'utc_offset' : january_offset, 135 | 'dst': 0, 136 | 'hemisphere' : jstz.HEMISPHERE_UNKNOWN 137 | }; 138 | }; 139 | 140 | jstz.get_january_offset = function () { 141 | return jstz.get_date_offset(new Date(2011, 0, 1, 0, 0, 0, 0)); 142 | }; 143 | 144 | jstz.get_june_offset = function () { 145 | return jstz.get_date_offset(new Date(2011, 5, 1, 0, 0, 0, 0)); 146 | }; 147 | 148 | /** 149 | * Uses get_timezone_info() to formulate a key to use in the olson.timezones dictionary. 150 | * 151 | * Returns a primitive object on the format: 152 | * {'timezone': TimeZone, 'key' : 'the key used to find the TimeZone object'} 153 | * 154 | * @returns Object 155 | */ 156 | jstz.determine_timezone = function () { 157 | var timezone_key_info, hemisphere_suffix, tz_key; 158 | timezone_key_info = jstz.get_timezone_info(); 159 | hemisphere_suffix = ''; 160 | 161 | if (timezone_key_info.hemisphere === jstz.HEMISPHERE_SOUTH) { 162 | hemisphere_suffix = ',s'; 163 | } 164 | 165 | tz_key = timezone_key_info.utc_offset + ',' + timezone_key_info.dst + hemisphere_suffix; 166 | 167 | return {'timezone' : jstz.olson.timezones[tz_key], 'key' : tz_key}; 168 | }; 169 | 170 | /** 171 | * The keys in this dictionary are comma separated as such: 172 | * 173 | * First the offset compared to UTC time in minutes. 174 | * 175 | * Then a flag which is 0 if the timezone does not take daylight savings into account and 1 if it does. 176 | * 177 | * Thirdly an optional 's' signifies that the timezone is in the southern hemisphere, only interesting for timezones with DST. 178 | * 179 | * The values of the dictionary are TimeZone objects. 180 | */ 181 | jstz.olson.timezones = { 182 | '-720,0' : new jstz.TimeZone('-12:00', 'Etc/GMT+12', false), 183 | '-660,0' : new jstz.TimeZone('-11:00', 'Pacific/Pago_Pago', false), 184 | '-600,1' : new jstz.TimeZone('-11:00', 'America/Adak', true), 185 | '-660,1,s' : new jstz.TimeZone('-11:00', 'Pacific/Apia', true), 186 | '-600,0' : new jstz.TimeZone('-10:00', 'Pacific/Honolulu', false), 187 | '-570,0' : new jstz.TimeZone('-10:30', 'Pacific/Marquesas', false), 188 | '-540,0' : new jstz.TimeZone('-09:00', 'Pacific/Gambier', false), 189 | '-540,1' : new jstz.TimeZone('-09:00', 'America/Anchorage', true), 190 | '-480,1' : new jstz.TimeZone('-08:00', 'America/Los_Angeles', true), 191 | '-480,0' : new jstz.TimeZone('-08:00', 'Pacific/Pitcairn', false), 192 | '-420,0' : new jstz.TimeZone('-07:00', 'America/Phoenix', false), 193 | '-420,1' : new jstz.TimeZone('-07:00', 'America/Denver', true), 194 | '-360,0' : new jstz.TimeZone('-06:00', 'America/Guatemala', false), 195 | '-360,1' : new jstz.TimeZone('-06:00', 'America/Chicago', true), 196 | '-360,1,s' : new jstz.TimeZone('-06:00', 'Pacific/Easter', true), 197 | '-300,0' : new jstz.TimeZone('-05:00', 'America/Bogota', false), 198 | '-300,1' : new jstz.TimeZone('-05:00', 'America/New_York', true), 199 | '-270,0' : new jstz.TimeZone('-04:30', 'America/Caracas', false), 200 | '-240,1' : new jstz.TimeZone('-04:00', 'America/Halifax', true), 201 | '-240,0' : new jstz.TimeZone('-04:00', 'America/Santo_Domingo', false), 202 | '-240,1,s' : new jstz.TimeZone('-04:00', 'America/Asuncion', true), 203 | '-210,1' : new jstz.TimeZone('-03:30', 'America/St_Johns', true), 204 | '-180,1' : new jstz.TimeZone('-03:00', 'America/Godthab', true), 205 | '-180,0' : new jstz.TimeZone('-03:00', 'America/Argentina/Buenos_Aires', false), 206 | '-180,1,s' : new jstz.TimeZone('-03:00', 'America/Montevideo', true), 207 | '-120,0' : new jstz.TimeZone('-02:00', 'America/Noronha', false), 208 | '-120,1' : new jstz.TimeZone('-02:00', 'Etc/GMT+2', true), 209 | '-60,1' : new jstz.TimeZone('-01:00', 'Atlantic/Azores', true), 210 | '-60,0' : new jstz.TimeZone('-01:00', 'Atlantic/Cape_Verde', false), 211 | '0,0' : new jstz.TimeZone('00:00', 'Etc/UTC', false), 212 | '0,1' : new jstz.TimeZone('00:00', 'Europe/London', true), 213 | '60,1' : new jstz.TimeZone('+01:00', 'Europe/Berlin', true), 214 | '60,0' : new jstz.TimeZone('+01:00', 'Africa/Lagos', false), 215 | '60,1,s' : new jstz.TimeZone('+01:00', 'Africa/Windhoek', true), 216 | '120,1' : new jstz.TimeZone('+02:00', 'Asia/Beirut', true), 217 | '120,0' : new jstz.TimeZone('+02:00', 'Africa/Johannesburg', false), 218 | '180,1' : new jstz.TimeZone('+03:00', 'Europe/Moscow', true), 219 | '180,0' : new jstz.TimeZone('+03:00', 'Asia/Baghdad', false), 220 | '210,1' : new jstz.TimeZone('+03:30', 'Asia/Tehran', true), 221 | '240,0' : new jstz.TimeZone('+04:00', 'Asia/Dubai', false), 222 | '240,1' : new jstz.TimeZone('+04:00', 'Asia/Yerevan', true), 223 | '270,0' : new jstz.TimeZone('+04:30', 'Asia/Kabul', false), 224 | '300,1' : new jstz.TimeZone('+05:00', 'Asia/Yekaterinburg', true), 225 | '300,0' : new jstz.TimeZone('+05:00', 'Asia/Karachi', false), 226 | '330,0' : new jstz.TimeZone('+05:30', 'Asia/Kolkata', false), 227 | '345,0' : new jstz.TimeZone('+05:45', 'Asia/Kathmandu', false), 228 | '360,0' : new jstz.TimeZone('+06:00', 'Asia/Dhaka', false), 229 | '360,1' : new jstz.TimeZone('+06:00', 'Asia/Omsk', true), 230 | '390,0' : new jstz.TimeZone('+06:30', 'Asia/Rangoon', false), 231 | '420,1' : new jstz.TimeZone('+07:00', 'Asia/Krasnoyarsk', true), 232 | '420,0' : new jstz.TimeZone('+07:00', 'Asia/Jakarta', false), 233 | '480,0' : new jstz.TimeZone('+08:00', 'Asia/Shanghai', false), 234 | '480,1' : new jstz.TimeZone('+08:00', 'Asia/Irkutsk', true), 235 | '525,0' : new jstz.TimeZone('+08:45', 'Australia/Eucla', true), 236 | '525,1,s' : new jstz.TimeZone('+08:45', 'Australia/Eucla', true), 237 | '540,1' : new jstz.TimeZone('+09:00', 'Asia/Yakutsk', true), 238 | '540,0' : new jstz.TimeZone('+09:00', 'Asia/Tokyo', false), 239 | '570,0' : new jstz.TimeZone('+09:30', 'Australia/Darwin', false), 240 | '570,1,s' : new jstz.TimeZone('+09:30', 'Australia/Adelaide', true), 241 | '600,0' : new jstz.TimeZone('+10:00', 'Australia/Brisbane', false), 242 | '600,1' : new jstz.TimeZone('+10:00', 'Asia/Vladivostok', true), 243 | '600,1,s' : new jstz.TimeZone('+10:00', 'Australia/Sydney', true), 244 | '630,1,s' : new jstz.TimeZone('+10:30', 'Australia/Lord_Howe', true), 245 | '660,1' : new jstz.TimeZone('+11:00', 'Asia/Kamchatka', true), 246 | '660,0' : new jstz.TimeZone('+11:00', 'Pacific/Noumea', false), 247 | '690,0' : new jstz.TimeZone('+11:30', 'Pacific/Norfolk', false), 248 | '720,1,s' : new jstz.TimeZone('+12:00', 'Pacific/Auckland', true), 249 | '720,0' : new jstz.TimeZone('+12:00', 'Pacific/Tarawa', false), 250 | '765,1,s' : new jstz.TimeZone('+12:45', 'Pacific/Chatham', true), 251 | '780,0' : new jstz.TimeZone('+13:00', 'Pacific/Tongatapu', false), 252 | '840,0' : new jstz.TimeZone('+14:00', 'Pacific/Kiritimati', false) 253 | }; 254 | 255 | /** 256 | * This object contains information on when daylight savings starts for 257 | * different timezones. 258 | * 259 | * The list is short for a reason. Often we do not have to be very specific 260 | * to single out the correct timezone. But when we do, this list comes in 261 | * handy. 262 | * 263 | * Each value is a date denoting when daylight savings starts for that timezone. 264 | */ 265 | jstz.olson.dst_start_dates = { 266 | 'America/Denver' : new Date(2011, 2, 13, 3, 0, 0, 0), 267 | 'America/Mazatlan' : new Date(2011, 3, 3, 3, 0, 0, 0), 268 | 'America/Chicago' : new Date(2011, 2, 13, 3, 0, 0, 0), 269 | 'America/Mexico_City' : new Date(2011, 3, 3, 3, 0, 0, 0), 270 | 'Atlantic/Stanley' : new Date(2011, 8, 4, 7, 0, 0, 0), 271 | 'America/Asuncion' : new Date(2011, 9, 2, 3, 0, 0, 0), 272 | 'America/Santiago' : new Date(2011, 9, 9, 3, 0, 0, 0), 273 | 'America/Campo_Grande' : new Date(2011, 9, 16, 5, 0, 0, 0), 274 | 'America/Montevideo' : new Date(2011, 9, 2, 3, 0, 0, 0), 275 | 'America/Sao_Paulo' : new Date(2011, 9, 16, 5, 0, 0, 0), 276 | 'America/Los_Angeles' : new Date(2011, 2, 13, 8, 0, 0, 0), 277 | 'America/Santa_Isabel' : new Date(2011, 3, 5, 8, 0, 0, 0), 278 | 'America/Havana' : new Date(2011, 2, 13, 2, 0, 0, 0), 279 | 'America/New_York' : new Date(2011, 2, 13, 7, 0, 0, 0), 280 | 'Asia/Gaza' : new Date(2011, 2, 26, 23, 0, 0, 0), 281 | 'Asia/Beirut' : new Date(2011, 2, 27, 1, 0, 0, 0), 282 | 'Europe/Minsk' : new Date(2011, 2, 27, 3, 0, 0, 0), 283 | 'Europe/Istanbul' : new Date(2011, 2, 27, 7, 0, 0, 0), 284 | 'Asia/Damascus' : new Date(2011, 3, 1, 2, 0, 0, 0), 285 | 'Asia/Jerusalem' : new Date(2011, 3, 1, 6, 0, 0, 0), 286 | 'Africa/Cairo' : new Date(2011, 3, 29, 4, 0, 0, 0), 287 | 'Asia/Yerevan' : new Date(2011, 2, 27, 4, 0, 0, 0), 288 | 'Asia/Baku' : new Date(2011, 2, 27, 8, 0, 0, 0), 289 | 'Pacific/Auckland' : new Date(2011, 8, 26, 7, 0, 0, 0), 290 | 'Pacific/Fiji' : new Date(2010, 11, 29, 23, 0, 0, 0), 291 | 'America/Halifax' : new Date(2011, 2, 13, 6, 0, 0, 0), 292 | 'America/Goose_Bay' : new Date(2011, 2, 13, 2, 1, 0, 0), 293 | 'America/Miquelon' : new Date(2011, 2, 13, 5, 0, 0, 0), 294 | 'America/Godthab' : new Date(2011, 2, 27, 1, 0, 0, 0) 295 | }; 296 | 297 | /** 298 | * The keys in this object are timezones that we know may be ambiguous after 299 | * a preliminary scan through the olson_tz object. 300 | * 301 | * The array of timezones to compare must be in the order that daylight savings 302 | * starts for the regions. 303 | */ 304 | jstz.olson.ambiguity_list = { 305 | 'America/Denver' : ['America/Denver', 'America/Mazatlan'], 306 | 'America/Chicago' : ['America/Chicago', 'America/Mexico_City'], 307 | 'America/Asuncion' : ['Atlantic/Stanley', 'America/Asuncion', 'America/Santiago', 'America/Campo_Grande'], 308 | 'America/Montevideo' : ['America/Montevideo', 'America/Sao_Paulo'], 309 | 'Asia/Beirut' : ['Asia/Gaza', 'Asia/Beirut', 'Europe/Minsk', 'Europe/Istanbul', 'Asia/Damascus', 'Asia/Jerusalem', 'Africa/Cairo'], 310 | 'Asia/Yerevan' : ['Asia/Yerevan', 'Asia/Baku'], 311 | 'Pacific/Auckland' : ['Pacific/Auckland', 'Pacific/Fiji'], 312 | 'America/Los_Angeles' : ['America/Los_Angeles', 'America/Santa_Isabel'], 313 | 'America/New_York' : ['America/Havana', 'America/New_York'], 314 | 'America/Halifax' : ['America/Goose_Bay', 'America/Halifax'], 315 | 'America/Godthab' : ['America/Miquelon', 'America/Godthab'] 316 | }; 317 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/jquery.detect_timezone.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery Detect Timezone plugin 3 | * 4 | * Copyright (c) 2011 Scott Watermasysk (scottwater@gmail.com) 5 | * Provided under the Do Whatever You Want With This Code License. (same as detect_timezone). 6 | * 7 | */ 8 | 9 | (function( $ ){ 10 | 11 | $.fn.set_timezone = function(options) { 12 | 13 | this.val(this.get_timezone(options)); 14 | return this; 15 | }; 16 | 17 | $.fn.get_timezone = function(options) { 18 | 19 | var settings = { 20 | 'format' : 'olson', 21 | 'debug' : false, 22 | 'default' : 'America/New_York' 23 | }; 24 | 25 | if(options) { 26 | $.extend( settings, options ); 27 | } 28 | 29 | var tz_info = jstz.determine_timezone(); 30 | var timezone = tz_info.timezone; 31 | var timezone_text = settings['default'] 32 | if (timezone != 'undefined') { 33 | timezone.ambiguity_check(); 34 | timezone_text = timezone.olson_tz 35 | } else { 36 | if(settings.debug) { 37 | alert('no timezone to be found. using default.') 38 | } 39 | } 40 | switch (settings.format) { 41 | case "city": 42 | return timezone_text.split('/')[1]; 43 | break; 44 | default: 45 | return timezone_text; 46 | } 47 | }; 48 | 49 | })( jQuery ); 50 | --------------------------------------------------------------------------------