timezone-aware 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d122047b6267e0a9514a21357684487db632a1e5
4
+ data.tar.gz: 115c61829fe5041a0eaf34fa247d602faf5dee32
5
+ SHA512:
6
+ metadata.gz: adb37c47ede7ddd973eceaf7a4952147214ee309e8491a1ac1778834e489a6ba999965e8e1e811800921148dfdbeb2e7ad8e56bd40f545d8b89f801494288168
7
+ data.tar.gz: 0ef8a8815079267ea26c5beae7e6190f69f3e8dc0310d2f4b561a8c1a5c79524d7c668776d4c9aa3e344be89477cf31ff9dedf0c0d5ced413d6d25ce8845ba83
@@ -0,0 +1,16 @@
1
+ .DS_Store
2
+ *~
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ *.bundle
13
+ *.so
14
+ *.o
15
+ *.a
16
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in timezone_aware.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Geoff Hayes
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # TimezoneAware
2
+
3
+ Timezone aware uses JavaScript to detect a user's timezone. After the user's own timezone is detected (i.e. after the first request), `Time.zone` is set automatically in an `around_filter` for each request. In your views and controllers, you can simply call `Time.zone.now` and know this will be in the user's local time.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'timezone-aware'
11
+ ```
12
+
13
+ Add `timezone-aware.js` to `application.js`
14
+
15
+ ```javascript
16
+ //=require timezone-aware
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install timezone-aware
26
+
27
+ ## Usage
28
+
29
+ Timezone aware automatically sets `Time.zone` during each request. After the JavaScript determines the user's timezone (via [jstz.js](http://pellepim.bitbucket.org/jstz/)), we set a cookie `time_zone`. Timezone aware then sets `Time.zone` based on this cookie in an `around_filter`.
30
+
31
+ **Note: this is not thread safe as global Time.zone is being set for each request.**
32
+
33
+ ## Examples
34
+
35
+ An example view: **home.html.erb**
36
+ ```ruby
37
+ The time is now <%= Time.zone.now %>
38
+ ```
39
+
40
+ Converting time zone back and forth
41
+ ```ruby
42
+ Time.now.utc.in_time_zone(Time.zone)
43
+ ```
44
+
45
+ ## TODO
46
+
47
+ * Add Poltergiest test cases
48
+ * Explore ways to get correct timezone on first request
49
+ * Explore ways to make thread safe
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it ( https://github.com/hayesgm/timezone-aware/fork )
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ //= require jstz
2
+ //= require docCookies
3
+
4
+ /**
5
+ * @author Geoffrey Hayes
6
+ */
7
+
8
+ (function(jstz, docCookies){
9
+
10
+ var timezoneAware = function() {
11
+ if ( ! docCookies.getItem('time_zone') ) {
12
+ var timezone = jstz.determine();
13
+
14
+ if (timezone) {
15
+ docCookies.setItem('time_zone', timezone.name(), 60*60*24*7, '/');
16
+ }
17
+ }
18
+ };
19
+
20
+ // Run automatically
21
+ timezoneAware();
22
+
23
+ })(jstz, docCookies);
@@ -0,0 +1,6 @@
1
+ require 'timezone-aware/version'
2
+ require 'timezone-aware/engine'
3
+
4
+ module TimezoneAware
5
+
6
+ end
@@ -0,0 +1,13 @@
1
+ require 'timezone-aware/helpers'
2
+
3
+ module TimezoneAware
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ initializer "timezone-aware.load_helpers" do
7
+ ActiveSupport.on_load(:action_controller) do
8
+ include TimezoneAware::Helpers
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ require 'active_support/concern'
2
+
3
+ module TimezoneAware
4
+ module Helpers
5
+ extend ActiveSupport::Concern
6
+
7
+ # Gets timezone
8
+ def user_time_zone
9
+ ActiveSupport::TimeZone[cookies[:time_zone]] if cookies[:time_zone]
10
+ end
11
+
12
+ # Note, this is not thread safe
13
+ def set_time_zone
14
+ old_time_zone = Time.zone
15
+
16
+ new_time_zone = user_time_zone()
17
+
18
+ Time.zone = new_time_zone if new_time_zone
19
+
20
+ yield
21
+ ensure # make sure we restore old time zone
22
+ Time.zone = old_time_zone
23
+ end
24
+
25
+ included do
26
+ around_filter :set_time_zone
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module TimezoneAware
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'timezone-aware/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "timezone-aware"
8
+ spec.version = TimezoneAware::VERSION
9
+ spec.authors = ["Geoff Hayes"]
10
+ spec.email = ["hayesgm@gmail.com"]
11
+ spec.summary = %q{Rails timezone set automatically to browser's own timezone.}
12
+ spec.description = %q{Timezone Aware tracks a user's timezone and sets Time.zone to that for each individual request.}
13
+ spec.homepage = "http://github.com/hayesgm/timezone-aware"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "railties"
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
@@ -0,0 +1,64 @@
1
+ // From https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
2
+ /*\
3
+ |*|
4
+ |*| :: cookies.js ::
5
+ |*|
6
+ |*| A complete cookies reader/writer framework with full unicode support.
7
+ |*|
8
+ |*| Revision #1 - September 4, 2014
9
+ |*|
10
+ |*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
11
+ |*| https://developer.mozilla.org/User:fusionchess
12
+ |*|
13
+ |*| This framework is released under the GNU Public License, version 3 or later.
14
+ |*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
15
+ |*|
16
+ |*| Syntaxes:
17
+ |*|
18
+ |*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
19
+ |*| * docCookies.getItem(name)
20
+ |*| * docCookies.removeItem(name[, path[, domain]])
21
+ |*| * docCookies.hasItem(name)
22
+ |*| * docCookies.keys()
23
+ |*|
24
+ \*/
25
+
26
+ var docCookies = {
27
+ getItem: function (sKey) {
28
+ if (!sKey) { return null; }
29
+ return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
30
+ },
31
+ setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
32
+ if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
33
+ var sExpires = "";
34
+ if (vEnd) {
35
+ switch (vEnd.constructor) {
36
+ case Number:
37
+ sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
38
+ break;
39
+ case String:
40
+ sExpires = "; expires=" + vEnd;
41
+ break;
42
+ case Date:
43
+ sExpires = "; expires=" + vEnd.toUTCString();
44
+ break;
45
+ }
46
+ }
47
+ document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
48
+ return true;
49
+ },
50
+ removeItem: function (sKey, sPath, sDomain) {
51
+ if (!this.hasItem(sKey)) { return false; }
52
+ document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
53
+ return true;
54
+ },
55
+ hasItem: function (sKey) {
56
+ if (!sKey) { return false; }
57
+ return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
58
+ },
59
+ keys: function () {
60
+ var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
61
+ for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }
62
+ return aKeys;
63
+ }
64
+ };
@@ -0,0 +1,348 @@
1
+ /**
2
+ * This script gives you the zone info key representing your device's time zone setting.
3
+ *
4
+ * @name jsTimezoneDetect
5
+ * @version 1.0.4
6
+ * @author Jon Nylander
7
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php
8
+ *
9
+ * For usage and examples, visit:
10
+ * http://pellepim.bitbucket.org/jstz/
11
+ *
12
+ * Copyright (c) Jon Nylander
13
+ */
14
+
15
+ /*jslint undef: true */
16
+ /*global console, exports*/
17
+
18
+ (function(root) {
19
+ /**
20
+ * Namespace to hold all the code for timezone detection.
21
+ */
22
+ var jstz = (function () {
23
+ 'use strict';
24
+ var HEMISPHERE_SOUTH = 's',
25
+
26
+ /**
27
+ * Gets the offset in minutes from UTC for a certain date.
28
+ * @param {Date} date
29
+ * @returns {Number}
30
+ */
31
+ get_date_offset = function (date) {
32
+ var offset = -date.getTimezoneOffset();
33
+ return (offset !== null ? offset : 0);
34
+ },
35
+
36
+ get_date = function (year, month, date) {
37
+ var d = new Date();
38
+ if (year !== undefined) {
39
+ d.setFullYear(year);
40
+ }
41
+ d.setDate(date);
42
+ d.setMonth(month);
43
+ return d;
44
+ },
45
+
46
+ get_january_offset = function (year) {
47
+ return get_date_offset(get_date(year, 0 ,2));
48
+ },
49
+
50
+ get_june_offset = function (year) {
51
+
52
+ return get_date_offset(get_date(year, 5, 2));
53
+ },
54
+
55
+ /**
56
+ * Private method.
57
+ * Checks whether a given date is in daylight savings time.
58
+ * If the date supplied is after august, we assume that we're checking
59
+ * for southern hemisphere DST.
60
+ * @param {Date} date
61
+ * @returns {Boolean}
62
+ */
63
+ date_is_dst = function (date) {
64
+ var base_offset = ((date.getMonth() > 7 ? get_june_offset(date.getFullYear())
65
+ : get_january_offset(date.getFullYear()))),
66
+ date_offset = get_date_offset(date);
67
+
68
+
69
+ return (base_offset - date_offset) !== 0;
70
+ },
71
+
72
+ /**
73
+ * This function does some basic calculations to create information about
74
+ * the user's timezone.
75
+ *
76
+ * Returns a key that can be used to do lookups in jstz.olson.timezones.
77
+ *
78
+ * @returns {String}
79
+ */
80
+
81
+ lookup_key = function () {
82
+ var january_offset = get_january_offset(),
83
+ june_offset = get_june_offset(),
84
+ diff = get_january_offset() - get_june_offset();
85
+
86
+ if (diff < 0) {
87
+ return january_offset + ",1";
88
+ } else if (diff > 0) {
89
+ return june_offset + ",1," + HEMISPHERE_SOUTH;
90
+ }
91
+
92
+ return january_offset + ",0";
93
+ },
94
+
95
+ /**
96
+ * Uses get_timezone_info() to formulate a key to use in the olson.timezones dictionary.
97
+ *
98
+ * Returns a primitive object on the format:
99
+ * {'timezone': TimeZone, 'key' : 'the key used to find the TimeZone object'}
100
+ *
101
+ * @returns Object
102
+ */
103
+ determine = function () {
104
+ var key = lookup_key();
105
+ return new jstz.TimeZone(jstz.olson.timezones[key]);
106
+ },
107
+
108
+ /**
109
+ * This object contains information on when daylight savings starts for
110
+ * different timezones.
111
+ *
112
+ * The list is short for a reason. Often we do not have to be very specific
113
+ * to single out the correct timezone. But when we do, this list comes in
114
+ * handy.
115
+ *
116
+ * Each value is a date denoting when daylight savings starts for that timezone.
117
+ */
118
+ dst_start_for = function (tz_name) {
119
+
120
+ var ru_pre_dst_change = new Date(2010, 6, 15, 1, 0, 0, 0), // In 2010 Russia had DST, this allows us to detect Russia :)
121
+ dst_starts = {
122
+ 'America/Denver': new Date(2011, 2, 13, 3, 0, 0, 0),
123
+ 'America/Mazatlan': new Date(2011, 3, 3, 3, 0, 0, 0),
124
+ 'America/Chicago': new Date(2011, 2, 13, 3, 0, 0, 0),
125
+ 'America/Mexico_City': new Date(2011, 3, 3, 3, 0, 0, 0),
126
+ 'America/Asuncion': new Date(2012, 9, 7, 3, 0, 0, 0),
127
+ 'America/Santiago': new Date(2012, 9, 3, 3, 0, 0, 0),
128
+ 'America/Campo_Grande': new Date(2012, 9, 21, 5, 0, 0, 0),
129
+ 'America/Montevideo': new Date(2011, 9, 2, 3, 0, 0, 0),
130
+ 'America/Sao_Paulo': new Date(2011, 9, 16, 5, 0, 0, 0),
131
+ 'America/Los_Angeles': new Date(2011, 2, 13, 8, 0, 0, 0),
132
+ 'America/Santa_Isabel': new Date(2011, 3, 5, 8, 0, 0, 0),
133
+ 'America/Havana': new Date(2012, 2, 10, 2, 0, 0, 0),
134
+ 'America/New_York': new Date(2012, 2, 10, 7, 0, 0, 0),
135
+ 'Asia/Beirut': new Date(2011, 2, 27, 1, 0, 0, 0),
136
+ 'Europe/Helsinki': new Date(2011, 2, 27, 4, 0, 0, 0),
137
+ 'Europe/Istanbul': new Date(2011, 2, 28, 5, 0, 0, 0),
138
+ 'Asia/Damascus': new Date(2011, 3, 1, 2, 0, 0, 0),
139
+ 'Asia/Jerusalem': new Date(2011, 3, 1, 6, 0, 0, 0),
140
+ 'Asia/Gaza': new Date(2009, 2, 28, 0, 30, 0, 0),
141
+ 'Africa/Cairo': new Date(2009, 3, 25, 0, 30, 0, 0),
142
+ 'Pacific/Auckland': new Date(2011, 8, 26, 7, 0, 0, 0),
143
+ 'Pacific/Fiji': new Date(2010, 11, 29, 23, 0, 0, 0),
144
+ 'America/Halifax': new Date(2011, 2, 13, 6, 0, 0, 0),
145
+ 'America/Goose_Bay': new Date(2011, 2, 13, 2, 1, 0, 0),
146
+ 'America/Miquelon': new Date(2011, 2, 13, 5, 0, 0, 0),
147
+ 'America/Godthab': new Date(2011, 2, 27, 1, 0, 0, 0),
148
+ 'Europe/Moscow': ru_pre_dst_change,
149
+ 'Asia/Yekaterinburg': ru_pre_dst_change,
150
+ 'Asia/Omsk': ru_pre_dst_change,
151
+ 'Asia/Krasnoyarsk': ru_pre_dst_change,
152
+ 'Asia/Irkutsk': ru_pre_dst_change,
153
+ 'Asia/Yakutsk': ru_pre_dst_change,
154
+ 'Asia/Vladivostok': ru_pre_dst_change,
155
+ 'Asia/Kamchatka': ru_pre_dst_change,
156
+ 'Europe/Minsk': ru_pre_dst_change,
157
+ 'Australia/Perth': new Date(2008, 10, 1, 1, 0, 0, 0)
158
+ };
159
+
160
+ return dst_starts[tz_name];
161
+ };
162
+
163
+ return {
164
+ determine: determine,
165
+ date_is_dst: date_is_dst,
166
+ dst_start_for: dst_start_for
167
+ };
168
+ }());
169
+
170
+ /**
171
+ * Simple object to perform ambiguity check and to return name of time zone.
172
+ */
173
+ jstz.TimeZone = function (tz_name) {
174
+ 'use strict';
175
+ /**
176
+ * The keys in this object are timezones that we know may be ambiguous after
177
+ * a preliminary scan through the olson_tz object.
178
+ *
179
+ * The array of timezones to compare must be in the order that daylight savings
180
+ * starts for the regions.
181
+ *
182
+ * @TODO: Once 2013 is upon us, remove Asia/Gaza from the Beirut ambiguity list,
183
+ * by then it should suffice that it lives in the Africa/Johannesburg check.
184
+ */
185
+ var AMBIGUITIES = {
186
+ 'America/Denver': ['America/Denver', 'America/Mazatlan'],
187
+ 'America/Chicago': ['America/Chicago', 'America/Mexico_City'],
188
+ 'America/Santiago': ['America/Santiago', 'America/Asuncion', 'America/Campo_Grande'],
189
+ 'America/Montevideo': ['America/Montevideo', 'America/Sao_Paulo'],
190
+ 'Asia/Beirut': ['Asia/Beirut', 'Europe/Helsinki', 'Europe/Istanbul', 'Asia/Damascus', 'Asia/Jerusalem', 'Asia/Gaza'],
191
+ 'Pacific/Auckland': ['Pacific/Auckland', 'Pacific/Fiji'],
192
+ 'America/Los_Angeles': ['America/Los_Angeles', 'America/Santa_Isabel'],
193
+ 'America/New_York': ['America/Havana', 'America/New_York'],
194
+ 'America/Halifax': ['America/Goose_Bay', 'America/Halifax'],
195
+ 'America/Godthab': ['America/Miquelon', 'America/Godthab'],
196
+ 'Asia/Dubai': ['Europe/Moscow'],
197
+ 'Asia/Dhaka': ['Asia/Yekaterinburg'],
198
+ 'Asia/Jakarta': ['Asia/Omsk'],
199
+ 'Asia/Shanghai': ['Asia/Krasnoyarsk', 'Australia/Perth'],
200
+ 'Asia/Tokyo': ['Asia/Irkutsk'],
201
+ 'Australia/Brisbane': ['Asia/Yakutsk'],
202
+ 'Pacific/Noumea': ['Asia/Vladivostok'],
203
+ 'Pacific/Tarawa': ['Asia/Kamchatka'],
204
+ 'Africa/Johannesburg': ['Asia/Gaza', 'Africa/Cairo'],
205
+ 'Asia/Baghdad': ['Europe/Minsk']
206
+ },
207
+
208
+ timezone_name = tz_name,
209
+
210
+ /**
211
+ * Checks if a timezone has possible ambiguities. I.e timezones that are similar.
212
+ *
213
+ * For example, if the preliminary scan determines that we're in America/Denver.
214
+ * We double check here that we're really there and not in America/Mazatlan.
215
+ *
216
+ * This is done by checking known dates for when daylight savings start for different
217
+ * timezones during 2010 and 2011.
218
+ */
219
+ ambiguity_check = function () {
220
+ var ambiguity_list = AMBIGUITIES[timezone_name],
221
+ length = ambiguity_list.length,
222
+ i = 0,
223
+ tz = ambiguity_list[0];
224
+
225
+ for (; i < length; i += 1) {
226
+ tz = ambiguity_list[i];
227
+
228
+ if (jstz.date_is_dst(jstz.dst_start_for(tz))) {
229
+ timezone_name = tz;
230
+ return;
231
+ }
232
+ }
233
+ },
234
+
235
+ /**
236
+ * Checks if it is possible that the timezone is ambiguous.
237
+ */
238
+ is_ambiguous = function () {
239
+ return typeof (AMBIGUITIES[timezone_name]) !== 'undefined';
240
+ };
241
+
242
+ if (is_ambiguous()) {
243
+ ambiguity_check();
244
+ }
245
+
246
+ return {
247
+ name: function () {
248
+ return timezone_name;
249
+ }
250
+ };
251
+ };
252
+
253
+ jstz.olson = {};
254
+
255
+ /*
256
+ * The keys in this dictionary are comma separated as such:
257
+ *
258
+ * First the offset compared to UTC time in minutes.
259
+ *
260
+ * Then a flag which is 0 if the timezone does not take daylight savings into account and 1 if it
261
+ * does.
262
+ *
263
+ * Thirdly an optional 's' signifies that the timezone is in the southern hemisphere,
264
+ * only interesting for timezones with DST.
265
+ *
266
+ * The mapped arrays is used for constructing the jstz.TimeZone object from within
267
+ * jstz.determine_timezone();
268
+ */
269
+ jstz.olson.timezones = {
270
+ '-720,0' : 'Etc/GMT+12',
271
+ '-660,0' : 'Pacific/Pago_Pago',
272
+ '-600,1' : 'America/Adak',
273
+ '-600,0' : 'Pacific/Honolulu',
274
+ '-570,0' : 'Pacific/Marquesas',
275
+ '-540,0' : 'Pacific/Gambier',
276
+ '-540,1' : 'America/Anchorage',
277
+ '-480,1' : 'America/Los_Angeles',
278
+ '-480,0' : 'Pacific/Pitcairn',
279
+ '-420,0' : 'America/Phoenix',
280
+ '-420,1' : 'America/Denver',
281
+ '-360,0' : 'America/Guatemala',
282
+ '-360,1' : 'America/Chicago',
283
+ '-360,1,s' : 'Pacific/Easter',
284
+ '-300,0' : 'America/Bogota',
285
+ '-300,1' : 'America/New_York',
286
+ '-270,0' : 'America/Caracas',
287
+ '-240,1' : 'America/Halifax',
288
+ '-240,0' : 'America/Santo_Domingo',
289
+ '-240,1,s' : 'America/Santiago',
290
+ '-210,1' : 'America/St_Johns',
291
+ '-180,1' : 'America/Godthab',
292
+ '-180,0' : 'America/Argentina/Buenos_Aires',
293
+ '-180,1,s' : 'America/Montevideo',
294
+ '-120,0' : 'Etc/GMT+2',
295
+ '-120,1' : 'Etc/GMT+2',
296
+ '-60,1' : 'Atlantic/Azores',
297
+ '-60,0' : 'Atlantic/Cape_Verde',
298
+ '0,0' : 'Etc/UTC',
299
+ '0,1' : 'Europe/London',
300
+ '60,1' : 'Europe/Berlin',
301
+ '60,0' : 'Africa/Lagos',
302
+ '60,1,s' : 'Africa/Windhoek',
303
+ '120,1' : 'Asia/Beirut',
304
+ '120,0' : 'Africa/Johannesburg',
305
+ '180,0' : 'Asia/Baghdad',
306
+ '180,1' : 'Europe/Moscow',
307
+ '210,1' : 'Asia/Tehran',
308
+ '240,0' : 'Asia/Dubai',
309
+ '240,1' : 'Asia/Baku',
310
+ '270,0' : 'Asia/Kabul',
311
+ '300,1' : 'Asia/Yekaterinburg',
312
+ '300,0' : 'Asia/Karachi',
313
+ '330,0' : 'Asia/Kolkata',
314
+ '345,0' : 'Asia/Kathmandu',
315
+ '360,0' : 'Asia/Dhaka',
316
+ '360,1' : 'Asia/Omsk',
317
+ '390,0' : 'Asia/Rangoon',
318
+ '420,1' : 'Asia/Krasnoyarsk',
319
+ '420,0' : 'Asia/Jakarta',
320
+ '480,0' : 'Asia/Shanghai',
321
+ '480,1' : 'Asia/Irkutsk',
322
+ '525,0' : 'Australia/Eucla',
323
+ '525,1,s' : 'Australia/Eucla',
324
+ '540,1' : 'Asia/Yakutsk',
325
+ '540,0' : 'Asia/Tokyo',
326
+ '570,0' : 'Australia/Darwin',
327
+ '570,1,s' : 'Australia/Adelaide',
328
+ '600,0' : 'Australia/Brisbane',
329
+ '600,1' : 'Asia/Vladivostok',
330
+ '600,1,s' : 'Australia/Sydney',
331
+ '630,1,s' : 'Australia/Lord_Howe',
332
+ '660,1' : 'Asia/Kamchatka',
333
+ '660,0' : 'Pacific/Noumea',
334
+ '690,0' : 'Pacific/Norfolk',
335
+ '720,1,s' : 'Pacific/Auckland',
336
+ '720,0' : 'Pacific/Tarawa',
337
+ '765,1,s' : 'Pacific/Chatham',
338
+ '780,0' : 'Pacific/Tongatapu',
339
+ '780,1,s' : 'Pacific/Apia',
340
+ '840,0' : 'Pacific/Kiritimati'
341
+ };
342
+
343
+ if (typeof exports !== 'undefined') {
344
+ exports.jstz = jstz;
345
+ } else {
346
+ root.jstz = jstz;
347
+ }
348
+ })(this);
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timezone-aware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Geoff Hayes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Timezone Aware tracks a user's timezone and sets Time.zone to that for
56
+ each individual request.
57
+ email:
58
+ - hayesgm@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - app/assets/javascripts/timezone-aware.js
69
+ - lib/timezone-aware.rb
70
+ - lib/timezone-aware/engine.rb
71
+ - lib/timezone-aware/helpers.rb
72
+ - lib/timezone-aware/version.rb
73
+ - timezone-aware.gemspec
74
+ - vendor/assets/javascripts/docCookies.js
75
+ - vendor/assets/javascripts/jstz.js
76
+ homepage: http://github.com/hayesgm/timezone-aware
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.1
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Rails timezone set automatically to browser's own timezone.
100
+ test_files: []
101
+ has_rdoc: