temporal-rails 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +26 -0
- data/lib/temporal-rails.rb +1 -0
- data/lib/temporal/controller_additions.rb +11 -0
- data/lib/temporal/engine.rb +11 -0
- data/lib/temporal/rails.rb +4 -0
- data/lib/temporal/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +3 -0
- data/spec/dummy/app/controllers/application_controller.rb +7 -0
- data/spec/dummy/app/views/layouts/application.html.erb +10 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +63 -0
- data/spec/dummy/config/boot.rb +9 -0
- data/spec/dummy/config/database.yml +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/evergreen.rb +47 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +62 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/javascripts/spec_helper.js +0 -0
- data/spec/javascripts/temporal_spec.js.coffee +4 -0
- data/vendor/assets/javascripts/temporal.js.coffee +195 -0
- metadata +204 -0
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Temporal uses Javascript timezone detection and sets Time.zone for
|
2
|
+
Rails to use.
|
3
|
+
|
4
|
+
Documentation and other useful information can be found at
|
5
|
+
https://github.com/jejacks0n/temporal
|
6
|
+
|
7
|
+
Copyright (c) 2011 Jeremy Jackson
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
10
|
+
a copy of this software and associated documentation files (the
|
11
|
+
"Software"), to deal in the Software without restriction, including
|
12
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
13
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
14
|
+
permit persons to whom the Software is furnished to do so, subject to
|
15
|
+
the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be
|
18
|
+
included in all copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
21
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
23
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
24
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'temporal/rails'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Temporal
|
2
|
+
module ControllerAdditions
|
3
|
+
def self.included(base)
|
4
|
+
base.send(:before_filter, :set_time_zone)
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_time_zone
|
8
|
+
Time.zone = ActiveSupport::TimeZone.new(cookies[:timezone]) || Rails.application.config.time_zone
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
require 'evergreen/rails'
|
5
|
+
|
6
|
+
if defined?(Bundler)
|
7
|
+
# If you precompile assets before deploying to production, use this line
|
8
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
9
|
+
# If you want your assets lazily compiled in production, use this line
|
10
|
+
# Bundler.require(:default, :assets, Rails.env)
|
11
|
+
end
|
12
|
+
|
13
|
+
module Dummy
|
14
|
+
class Application < Rails::Application
|
15
|
+
# Settings in config/environments/* take precedence over those specified here.
|
16
|
+
# Application configuration should go into files in config/initializers
|
17
|
+
# -- all .rb files in that directory are automatically loaded.
|
18
|
+
|
19
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
20
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
21
|
+
|
22
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
23
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
24
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
25
|
+
|
26
|
+
# Activate observers that should always be running.
|
27
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
28
|
+
|
29
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
30
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
31
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
32
|
+
|
33
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
34
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
35
|
+
# config.i18n.default_locale = :de
|
36
|
+
|
37
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
38
|
+
config.encoding = "utf-8"
|
39
|
+
|
40
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
41
|
+
config.filter_parameters += [:password]
|
42
|
+
|
43
|
+
# Enable escaping HTML in JSON.
|
44
|
+
config.active_support.escape_html_entities_in_json = true
|
45
|
+
|
46
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
47
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
48
|
+
# like if you have constraints or database-specific column types
|
49
|
+
config.active_record.schema_format = :sql
|
50
|
+
|
51
|
+
# Enforce whitelist mode for mass assignment.
|
52
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
53
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
54
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
55
|
+
config.active_record.whitelist_attributes = true
|
56
|
+
|
57
|
+
# Enable the asset pipeline
|
58
|
+
config.assets.enabled = true
|
59
|
+
|
60
|
+
# Version of your assets, change this if you want to expire all your assets
|
61
|
+
config.assets.version = '1.0'
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
#config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Raise exception on mass assignment protection for Active Record models
|
33
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
+
|
35
|
+
# Print deprecation notices to the stderr
|
36
|
+
config.active_support.deprecation = :stderr
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# The following allows us to have a nested directory structure of specs. With
|
2
|
+
# a lot of specs this is needed.
|
3
|
+
Evergreen.configure do |config|
|
4
|
+
config.root = Temporal::Engine.root
|
5
|
+
end
|
6
|
+
|
7
|
+
module Evergreen
|
8
|
+
class Suite
|
9
|
+
def specs
|
10
|
+
Dir.glob(File.join(root, Evergreen.spec_dir, '**', '*_spec.{js,coffee,js.coffee}')).map do |path|
|
11
|
+
Spec.new(self, path.gsub(File.join(root), ''))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def templates
|
16
|
+
Dir.glob(File.join(root, Evergreen.template_dir, '**', '*')).map do |path|
|
17
|
+
Template.new(self, path.gsub(File.join(root), '')) unless File.directory?(path)
|
18
|
+
end.compact
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Evergreen
|
24
|
+
class Spec
|
25
|
+
def initialize(suite, name)
|
26
|
+
@suite = suite
|
27
|
+
@name = name
|
28
|
+
@name = "#{Evergreen.spec_dir}/#{name}" if !exist?
|
29
|
+
end
|
30
|
+
|
31
|
+
def name
|
32
|
+
@name.gsub("/#{Evergreen.spec_dir}/", '')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Evergreen
|
38
|
+
class Template
|
39
|
+
def name
|
40
|
+
@name.gsub("/#{Evergreen.template_dir}/", '')
|
41
|
+
end
|
42
|
+
|
43
|
+
def full_path
|
44
|
+
File.join(root, @name)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
+
# inflect.acronym 'RESTful'
|
15
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = '990bac5b6d4f068883259503539cad4e9ec00f137986fcbc718a1e0b645af7a3eb0340468f8fae09958a6281190396d65789b6316af61e47a8cbda3c8c071a0e'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters :format => [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
|
3
|
+
match '/welcome' => 'application#welcome'
|
4
|
+
|
5
|
+
# The priority is based upon order of creation:
|
6
|
+
# first created -> highest priority.
|
7
|
+
|
8
|
+
# Sample of regular route:
|
9
|
+
# match 'products/:id' => 'catalog#view'
|
10
|
+
# Keep in mind you can assign values other than :controller and :action
|
11
|
+
|
12
|
+
# Sample of named route:
|
13
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
14
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
15
|
+
|
16
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
17
|
+
# resources :products
|
18
|
+
|
19
|
+
# Sample resource route with options:
|
20
|
+
# resources :products do
|
21
|
+
# member do
|
22
|
+
# get 'short'
|
23
|
+
# post 'toggle'
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# collection do
|
27
|
+
# get 'sold'
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# Sample resource route with sub-resources:
|
32
|
+
# resources :products do
|
33
|
+
# resources :comments, :sales
|
34
|
+
# resource :seller
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Sample resource route with more complex sub-resources
|
38
|
+
# resources :products do
|
39
|
+
# resources :comments
|
40
|
+
# resources :sales do
|
41
|
+
# get 'recent', :on => :collection
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
|
45
|
+
# Sample resource route within a namespace:
|
46
|
+
# namespace :admin do
|
47
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
48
|
+
# # (app/controllers/admin/products_controller.rb)
|
49
|
+
# resources :products
|
50
|
+
# end
|
51
|
+
|
52
|
+
# You can have the root of your site routed with "root"
|
53
|
+
# just remember to delete public/index.html.
|
54
|
+
# root :to => 'welcome#index'
|
55
|
+
|
56
|
+
# See how all your routes lay out with "rake routes"
|
57
|
+
|
58
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
59
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
60
|
+
# match ':controller(/:action(/:id))(.:format)'
|
61
|
+
|
62
|
+
end
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
File without changes
|
@@ -0,0 +1,195 @@
|
|
1
|
+
class TimeZone
|
2
|
+
|
3
|
+
constructor: (keyOrProperties) ->
|
4
|
+
if typeof(keyOrProperties) == 'string'
|
5
|
+
zone = TIMEZONES[keyOrProperties]
|
6
|
+
@[property] = value for own property, value of zone
|
7
|
+
@resolveAmbiguity()
|
8
|
+
else
|
9
|
+
@[property] = value for own property, value of keyOrProperties
|
10
|
+
|
11
|
+
resolveAmbiguity: ->
|
12
|
+
ambiguous = AMBIGIOUS_ZONES[@name]
|
13
|
+
return if typeof(ambiguous) is 'undefined'
|
14
|
+
for key, value of ambiguous
|
15
|
+
if Temporal.dateIsDst(DST_START_DATES[value])
|
16
|
+
@name = value
|
17
|
+
return
|
18
|
+
|
19
|
+
|
20
|
+
class Temporal
|
21
|
+
|
22
|
+
@detect: (@username = null, @callback = null) =>
|
23
|
+
timezone = @quick()
|
24
|
+
if timezone.offset != @get().offset
|
25
|
+
navigator.geolocation.getCurrentPosition(@geoSuccess, ->) if @username and navigator.geolocation
|
26
|
+
@set(timezone)
|
27
|
+
|
28
|
+
@geoSuccess: (position) =>
|
29
|
+
window[JSONP_CALLBACK] = @parseGeoResponse
|
30
|
+
script = document.createElement('script')
|
31
|
+
script.setAttribute('src', "http://api.geonames.org/timezoneJSON?lat=#{position.coords.latitude}&lng=#{position.coords.longitude}&username=#{@username}&callback=#{JSONP_CALLBACK}")
|
32
|
+
document.getElementsByTagName('head')[0].appendChild(script)
|
33
|
+
|
34
|
+
@parseGeoResponse: (response) =>
|
35
|
+
delete(window[JSONP_CALLBACK])
|
36
|
+
@set(new TimeZone(name: response.timezoneId, offset: response.rawOffset)) if response.timezoneId
|
37
|
+
|
38
|
+
@quick: =>
|
39
|
+
januaryOffset = @januaryOffset()
|
40
|
+
juneOffset = @juneOffset()
|
41
|
+
key = {offset: januaryOffset, dst: 0, hemisphere: HEMISPHERE_UNKNOWN}
|
42
|
+
if januaryOffset - juneOffset < 0
|
43
|
+
key = {offset: januaryOffset, dst: 1, hemisphere: HEMISPHERE_NORTH}
|
44
|
+
else if januaryOffset - juneOffset > 0
|
45
|
+
key = {offset: juneOffset, dst: 1, hemisphere: HEMISPHERE_SOUTH}
|
46
|
+
new TimeZone("#{([key.offset, key.dst].join(','))}#{if key.hemisphere is HEMISPHERE_SOUTH then ',s' else ''}")
|
47
|
+
|
48
|
+
@set: (timezone) ->
|
49
|
+
window.timezone = timezone
|
50
|
+
expiration = new Date()
|
51
|
+
expiration.setMonth(expiration.getMonth() + 1)
|
52
|
+
document.cookie = "timezone=#{timezone.name}; expires=#{expiration.toGMTString()}"
|
53
|
+
document.cookie = "timezone_offset=#{timezone.offset}"
|
54
|
+
@callback?(timezone)
|
55
|
+
|
56
|
+
@get: ->
|
57
|
+
name: @getCookie('timezone')
|
58
|
+
offset: parseFloat(@getCookie('timezone_offset'))
|
59
|
+
|
60
|
+
@getCookie: (name) ->
|
61
|
+
match = document.cookie.match(new RegExp("(?:^|;)\\s?#{name}=(.*?)(?:;|$)", 'i'))
|
62
|
+
match && unescape(match[1])
|
63
|
+
|
64
|
+
@januaryOffset: ->
|
65
|
+
@dateOffset(new Date(2011, 0, 1, 0, 0, 0, 0))
|
66
|
+
|
67
|
+
@juneOffset: ->
|
68
|
+
@dateOffset(new Date(2011, 5, 1, 0, 0, 0, 0))
|
69
|
+
|
70
|
+
@dateOffset: (date) ->
|
71
|
+
-date.getTimezoneOffset()
|
72
|
+
|
73
|
+
@dateIsDst: (date) ->
|
74
|
+
(((if date.getMonth() > 5 then @juneOffset() else @januaryOffset())) - @dateOffset(date)) isnt 0
|
75
|
+
|
76
|
+
JSONP_CALLBACK = "geoSuccessCallback#{parseInt(Math.random() * 10000)}"
|
77
|
+
HEMISPHERE_SOUTH = 'SOUTH'
|
78
|
+
HEMISPHERE_NORTH = 'NORTH'
|
79
|
+
HEMISPHERE_UNKNOWN = 'N/A'
|
80
|
+
AMBIGIOUS_ZONES =
|
81
|
+
'America/Denver': ['America/Denver', 'America/Mazatlan']
|
82
|
+
'America/Chicago': ['America/Chicago', 'America/Mexico_City']
|
83
|
+
'America/Asuncion': ['Atlantic/Stanley', 'America/Asuncion', 'America/Santiago', 'America/Campo_Grande']
|
84
|
+
'America/Montevideo': ['America/Montevideo', 'America/Sao_Paolo']
|
85
|
+
'Asia/Beirut': ['Asia/Gaza', 'Asia/Beirut', 'Europe/Minsk', 'Europe/Istanbul', 'Asia/Damascus', 'Asia/Jerusalem', 'Africa/Cairo']
|
86
|
+
'Asia/Yerevan': ['Asia/Yerevan', 'Asia/Baku']
|
87
|
+
'Pacific/Auckland': ['Pacific/Auckland', 'Pacific/Fiji']
|
88
|
+
'America/Los_Angeles': ['America/Los_Angeles', 'America/Santa_Isabel']
|
89
|
+
'America/New_York': ['America/Havana', 'America/New_York']
|
90
|
+
'America/Halifax': ['America/Goose_Bay', 'America/Halifax']
|
91
|
+
'America/Godthab': ['America/Miquelon', 'America/Godthab']
|
92
|
+
DST_START_DATES =
|
93
|
+
'America/Denver': new Date(2011, 2, 13, 3, 0, 0, 0)
|
94
|
+
'America/Mazatlan': new Date(2011, 3, 3, 3, 0, 0, 0)
|
95
|
+
'America/Chicago': new Date(2011, 2, 13, 3, 0, 0, 0)
|
96
|
+
'America/Mexico_City': new Date(2011, 3, 3, 3, 0, 0, 0)
|
97
|
+
'Atlantic/Stanley': new Date(2011, 8, 4, 7, 0, 0, 0)
|
98
|
+
'America/Asuncion': new Date(2011, 9, 2, 3, 0, 0, 0)
|
99
|
+
'America/Santiago': new Date(2011, 9, 9, 3, 0, 0, 0)
|
100
|
+
'America/Campo_Grande': new Date(2011, 9, 16, 5, 0, 0, 0)
|
101
|
+
'America/Montevideo': new Date(2011, 9, 2, 3, 0, 0, 0)
|
102
|
+
'America/Sao_Paolo': new Date(2011, 9, 16, 5, 0, 0, 0)
|
103
|
+
'America/Los_Angeles': new Date(2011, 2, 13, 8, 0, 0, 0)
|
104
|
+
'America/Santa_Isabel': new Date(2011, 3, 5, 8, 0, 0, 0)
|
105
|
+
'America/Havana': new Date(2011, 2, 13, 2, 0, 0, 0)
|
106
|
+
'America/New_York': new Date(2011, 2, 13, 7, 0, 0, 0)
|
107
|
+
'Asia/Gaza': new Date(2011, 2, 26, 23, 0, 0, 0)
|
108
|
+
'Asia/Beirut': new Date(2011, 2, 27, 1, 0, 0, 0)
|
109
|
+
'Europe/Minsk': new Date(2011, 2, 27, 3, 0, 0, 0)
|
110
|
+
'Europe/Istanbul': new Date(2011, 2, 27, 7, 0, 0, 0)
|
111
|
+
'Asia/Damascus': new Date(2011, 3, 1, 2, 0, 0, 0)
|
112
|
+
'Asia/Jerusalem': new Date(2011, 3, 1, 6, 0, 0, 0)
|
113
|
+
'Africa/Cairo': new Date(2011, 3, 29, 4, 0, 0, 0)
|
114
|
+
'Asia/Yerevan': new Date(2011, 2, 27, 4, 0, 0, 0)
|
115
|
+
'Asia/Baku': new Date(2011, 2, 27, 8, 0, 0, 0)
|
116
|
+
'Pacific/Auckland': new Date(2011, 8, 26, 7, 0, 0, 0)
|
117
|
+
'Pacific/Fiji': new Date(2010, 11, 29, 23, 0, 0, 0)
|
118
|
+
'America/Halifax': new Date(2011, 2, 13, 6, 0, 0, 0)
|
119
|
+
'America/Goose_Bay': new Date(2011, 2, 13, 2, 1, 0, 0)
|
120
|
+
'America/Miquelon': new Date(2011, 2, 13, 5, 0, 0, 0)
|
121
|
+
'America/Godthab': new Date(2011, 2, 27, 1, 0, 0, 0)
|
122
|
+
TIMEZONES =
|
123
|
+
'-720,0': {offset: -12, name: 'Etc/GMT+12'}
|
124
|
+
'-660,0': {offset: -11, name: 'Pacific/Pago_Pago'}
|
125
|
+
'-600,1': {offset: -11, name: 'America/Adak'}
|
126
|
+
'-660,1,s': {offset: -11, name: 'Pacific/Apia'}
|
127
|
+
'-600,0': {offset: -10, name: 'Pacific/Honolulu'}
|
128
|
+
'-570,0': {offset: -10.5, name: 'Pacific/Marquesas'}
|
129
|
+
'-540,0': {offset: -9, name: 'Pacific/Gambier'}
|
130
|
+
'-540,1': {offset: -9, name: 'America/Anchorage'}
|
131
|
+
'-480,1': {offset: -8, name: 'America/Los_Angeles'}
|
132
|
+
'-480,0': {offset: -8, name: 'Pacific/Pitcairn'}
|
133
|
+
'-420,0': {offset: -7, name: 'America/Phoenix'}
|
134
|
+
'-420,1': {offset: -7, name: 'America/Denver'}
|
135
|
+
'-360,0': {offset: -6, name: 'America/Guatemala'}
|
136
|
+
'-360,1': {offset: -6, name: 'America/Chicago'}
|
137
|
+
'-360,1,s': {offset: -6, name: 'Pacific/Easter'}
|
138
|
+
'-300,0': {offset: -5, name: 'America/Bogota'}
|
139
|
+
'-300,1': {offset: -5, name: 'America/New_York'}
|
140
|
+
'-270,0': {offset: -4.5, name: 'America/Caracas'}
|
141
|
+
'-240,1': {offset: -4, name: 'America/Halifax'}
|
142
|
+
'-240,0': {offset: -4, name: 'America/Santo_Domingo'}
|
143
|
+
'-240,1,s': {offset: -4, name: 'America/Asuncion'}
|
144
|
+
'-210,1': {offset: -3.5, name: 'America/St_Johns'}
|
145
|
+
'-180,1': {offset: -3, name: 'America/Godthab'}
|
146
|
+
'-180,0': {offset: -3, name: 'America/Argentina/Buenos_Aires,'}
|
147
|
+
'-180,1,s': {offset: -3, name: 'America/Montevideo'}
|
148
|
+
'-120,0': {offset: -2, name: 'America/Noronha'}
|
149
|
+
'-120,1': {offset: -2, name: 'Etc/GMT+2'}
|
150
|
+
'-60,1': {offset: -1, name: 'Atlantic/Azores'}
|
151
|
+
'-60,0': {offset: -1, name: 'Atlantic/Cape_Verde'}
|
152
|
+
'0,0': {offset: 0, name: 'Africa/Casablanca'}
|
153
|
+
'0,1': {offset: 0, name: 'Europe/London'}
|
154
|
+
'60,1': {offset: 1, name: 'Europe/Berlin'}
|
155
|
+
'60,0': {offset: 1, name: 'Africa/Lagos'}
|
156
|
+
'60,1,s': {offset: 1, name: 'Africa/Windhoek'}
|
157
|
+
'120,1': {offset: 2, name: 'Asia/Beirut'}
|
158
|
+
'120,0': {offset: 2, name: 'Africa/Johannesburg'}
|
159
|
+
'180,1': {offset: 3, name: 'Europe/Moscow'}
|
160
|
+
'180,0': {offset: 3, name: 'Asia/Baghdad'}
|
161
|
+
'210,1': {offset: 3.5, name: 'Asia/Tehran'}
|
162
|
+
'240,0': {offset: 4, name: 'Asia/Dubai'}
|
163
|
+
'240,1': {offset: 4, name: 'Asia/Yerevan'}
|
164
|
+
'270,0': {offset: 4.5, name: 'Asia/Kabul'}
|
165
|
+
'300,1': {offset: 5, name: 'Asia/Yekaterinburg'}
|
166
|
+
'300,0': {offset: 5, name: 'Asia/Karachi'}
|
167
|
+
'330,0': {offset: 5, name: 'Asia/Kolkata'}
|
168
|
+
'345,0': {offset: 5.75, name: 'Asia/Kathmandu'}
|
169
|
+
'360,0': {offset: 6, name: 'Asia/Dhaka'}
|
170
|
+
'360,1': {offset: 6, name: 'Asia/Omsk'}
|
171
|
+
'390,0': {offset: 6, name: 'Asia/Rangoon'}
|
172
|
+
'420,1': {offset: 7, name: 'Asia/Krasnoyarsk'}
|
173
|
+
'420,0': {offset: 7, name: 'Asia/Jakarta'}
|
174
|
+
'480,0': {offset: 8, name: 'Asia/Shanghai'}
|
175
|
+
'480,1': {offset: 8, name: 'Asia/Irkutsk'}
|
176
|
+
'525,0': {offset: 8.75, name: 'Australia/Eucla'}
|
177
|
+
'525,1,s': {offset: 8.75, name: 'Australia/Eucla'}
|
178
|
+
'540,1': {offset: 9, name: 'Asia/Yakutsk'}
|
179
|
+
'540,0': {offset: 9, name: 'Asia/Tokyo'}
|
180
|
+
'570,0': {offset: 9.5, name: 'Australia/Darwin'}
|
181
|
+
'570,1,s': {offset: 9.5, name: 'Australia/Adelaide'}
|
182
|
+
'600,0': {offset: 10, name: 'Australia/Brisbane'}
|
183
|
+
'600,1': {offset: 10, name: 'Asia/Vladivostok'}
|
184
|
+
'600,1,s': {offset: 10, name: 'Australia/Sydney'}
|
185
|
+
'630,1,s': {offset: 10.5, name: 'Australia/Lord_Howe'}
|
186
|
+
'660,1': {offset: 11, name: 'Asia/Kamchatka'}
|
187
|
+
'660,0': {offset: 11, name: 'Pacific/Noumea'}
|
188
|
+
'690,0': {offset: 11.5, name: 'Pacific/Norfolk'}
|
189
|
+
'720,1,s': {offset: 12, name: 'Pacific/Auckland'}
|
190
|
+
'720,0': {offset: 12, name: 'Pacific/Tarawa'}
|
191
|
+
'765,1,s': {offset: 12.75, name: 'Pacific/Chatham'}
|
192
|
+
'780,0': {offset: 13, name: 'Pacific/Tongatapu'}
|
193
|
+
'840,0': {offset: 14, name: 'Pacific/Kiritimati'}
|
194
|
+
|
195
|
+
@Temporal = {detect: Temporal.detect}
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: temporal-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeremy Jackson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.8
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: coffee-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sprockets
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: uglifier
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sprockets-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: evergreen
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.0.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.0
|
110
|
+
description: Javascript timezone detection that also sets Time.zone for Rails to use
|
111
|
+
email:
|
112
|
+
- jejacks0n@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- LICENSE
|
117
|
+
files:
|
118
|
+
- lib/temporal/controller_additions.rb
|
119
|
+
- lib/temporal/engine.rb
|
120
|
+
- lib/temporal/rails.rb
|
121
|
+
- lib/temporal/version.rb
|
122
|
+
- lib/temporal-rails.rb
|
123
|
+
- vendor/assets/javascripts/temporal.js.coffee
|
124
|
+
- LICENSE
|
125
|
+
- spec/dummy/Rakefile
|
126
|
+
- spec/dummy/app/assets/javascripts/application.js
|
127
|
+
- spec/dummy/app/controllers/application_controller.rb
|
128
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
129
|
+
- spec/dummy/config.ru
|
130
|
+
- spec/dummy/config/application.rb
|
131
|
+
- spec/dummy/config/boot.rb
|
132
|
+
- spec/dummy/config/database.yml
|
133
|
+
- spec/dummy/config/environment.rb
|
134
|
+
- spec/dummy/config/environments/development.rb
|
135
|
+
- spec/dummy/config/environments/test.rb
|
136
|
+
- spec/dummy/config/evergreen.rb
|
137
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
138
|
+
- spec/dummy/config/initializers/inflections.rb
|
139
|
+
- spec/dummy/config/initializers/mime_types.rb
|
140
|
+
- spec/dummy/config/initializers/secret_token.rb
|
141
|
+
- spec/dummy/config/initializers/session_store.rb
|
142
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
143
|
+
- spec/dummy/config/locales/en.yml
|
144
|
+
- spec/dummy/config/routes.rb
|
145
|
+
- spec/dummy/public/favicon.ico
|
146
|
+
- spec/dummy/script/rails
|
147
|
+
- spec/javascripts/spec_helper.js
|
148
|
+
- spec/javascripts/temporal_spec.js.coffee
|
149
|
+
homepage: http://github.com/jejacks0n/temporal
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
segments:
|
163
|
+
- 0
|
164
|
+
hash: -549914994606472815
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
segments:
|
172
|
+
- 0
|
173
|
+
hash: -549914994606472815
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 1.8.24
|
177
|
+
signing_key:
|
178
|
+
specification_version: 3
|
179
|
+
summary: ! 'Temporal: Javascript timezone detection for Rails'
|
180
|
+
test_files:
|
181
|
+
- spec/dummy/Rakefile
|
182
|
+
- spec/dummy/app/assets/javascripts/application.js
|
183
|
+
- spec/dummy/app/controllers/application_controller.rb
|
184
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
185
|
+
- spec/dummy/config.ru
|
186
|
+
- spec/dummy/config/application.rb
|
187
|
+
- spec/dummy/config/boot.rb
|
188
|
+
- spec/dummy/config/database.yml
|
189
|
+
- spec/dummy/config/environment.rb
|
190
|
+
- spec/dummy/config/environments/development.rb
|
191
|
+
- spec/dummy/config/environments/test.rb
|
192
|
+
- spec/dummy/config/evergreen.rb
|
193
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
194
|
+
- spec/dummy/config/initializers/inflections.rb
|
195
|
+
- spec/dummy/config/initializers/mime_types.rb
|
196
|
+
- spec/dummy/config/initializers/secret_token.rb
|
197
|
+
- spec/dummy/config/initializers/session_store.rb
|
198
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
199
|
+
- spec/dummy/config/locales/en.yml
|
200
|
+
- spec/dummy/config/routes.rb
|
201
|
+
- spec/dummy/public/favicon.ico
|
202
|
+
- spec/dummy/script/rails
|
203
|
+
- spec/javascripts/spec_helper.js
|
204
|
+
- spec/javascripts/temporal_spec.js.coffee
|