js-timezone-converter-rails 0.0.1
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.
@@ -0,0 +1,20 @@
|
|
1
|
+
!function($) {
|
2
|
+
Date.timezoneUTCOffsetFor = function( zone ) {
|
3
|
+
var offset = Date.availableTimezones()[zone];
|
4
|
+
if ( offset === void(0) )
|
5
|
+
throw("Unknown timezone '" + zone + "'");
|
6
|
+
return (offset * 1000);
|
7
|
+
};
|
8
|
+
|
9
|
+
Date.availableTimezones = function( zone ) {
|
10
|
+
return $('#js_timezone_converter_data').data('timezones');
|
11
|
+
}
|
12
|
+
|
13
|
+
Date.prototype.at = function( zone ) {
|
14
|
+
var offset = ( Date.timezoneUTCOffsetFor( zone ) +
|
15
|
+
((new Date()).getTimezoneOffset() * 60 * 1000)
|
16
|
+
);
|
17
|
+
return ( new Date( new Date( this ) - (- offset) ) );
|
18
|
+
};
|
19
|
+
|
20
|
+
}(window.jQuery);
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module JSTimeZoneConverterRails
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
initializer 'js-timezone-converter-rails.action_controller' do |app|
|
4
|
+
ActiveSupport.on_load :action_controller do
|
5
|
+
helper JSTimeZoneConverterRails::Helper
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Helper
|
11
|
+
def js_timezone_converter_data
|
12
|
+
content_tag "div", "", id: 'js_timezone_converter_data', data: {
|
13
|
+
timezones: Hash[ActiveSupport::TimeZone::MAPPING.keys.map { |zone|
|
14
|
+
tz = ActiveSupport::TimeZone.new zone
|
15
|
+
offset = tz.utc_offset
|
16
|
+
dst = tz.period_for_local(Time.now,true).dst?
|
17
|
+
[zone, dst ? (offset + 3600): offset]
|
18
|
+
}]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: js-timezone-converter-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Eran Barak Levi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: JavaScript Timezone Converter library for rails applications
|
15
|
+
email: wtf@wtf.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/js-timezone-converter-rails/engine.rb
|
21
|
+
- lib/js-timezone-converter-rails/version.rb
|
22
|
+
- lib/js-timezone-converter-rails.rb
|
23
|
+
- app/assets/javascripts/js-timezone-converter.js
|
24
|
+
homepage: http://github.com/eranb/js-timezone-converter-rails
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.8.5
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project: js-timezone-converter-rails
|
44
|
+
rubygems_version: 1.8.25
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: JavaScript Timezone Converter library
|
48
|
+
test_files: []
|