jstz-rails 1.0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +46 -0
- data/README.md +146 -0
- data/lib/jstz-rails.rb +8 -0
- data/lib/jstz-rails/version.rb +5 -0
- data/vendor/assets/javascripts/jstz.js +334 -0
- metadata +66 -0
data/LICENSE
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
Copyright (c) 2013 William Van Etten
|
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.
|
23
|
+
# jstz.js appended LICENSE #
|
24
|
+
|
25
|
+
MIT License
|
26
|
+
|
27
|
+
Copyright (c) 2012 Jon Nylander, project maintained at
|
28
|
+
https://bitbucket.org/pellepim/jstimezonedetect
|
29
|
+
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
31
|
+
of this software and associated documentation files (the "Software"), to deal
|
32
|
+
in the Software without restriction, including without limitation the rights to
|
33
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
34
|
+
of the Software, and to permit persons to whom the Software is furnished to
|
35
|
+
do so, subject to the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be included in
|
38
|
+
all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
41
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
42
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
43
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
44
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
45
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
46
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# Jstz::Rails
|
2
|
+
|
3
|
+
This is [jstz.js aka jsTimezoneDetect](https://bitbucket.org/pellepim/jstimezonedetect/) GEMified for the Rails >= 3.1 asset pipeline through the following:
|
4
|
+
|
5
|
+
bundle gem jstz-rails
|
6
|
+
cd jstz-rails
|
7
|
+
mkdir -p vendor/assets/javascripts
|
8
|
+
curl https://bitbucket.org/pellepim/jstimezonedetect/raw/c7ea46531444b600246fe651bc9feb66a7593be5/jstz.js -o vendor/assets/javascripts/jstz.js
|
9
|
+
echo "" >> README.md; echo "# jstz.js appended README #" >> README.md; echo "" >> README.md
|
10
|
+
curl https://bitbucket.org/pellepim/jstimezonedetect/raw/c7ea46531444b600246fe651bc9feb66a7593be5/README.md >> README.md
|
11
|
+
echo "" >> LICENSE; echo "# jstz.js appended LICENSE #" >> LICENSE; echo "" >> LICENSE
|
12
|
+
curl https://bitbucket.org/pellepim/jstimezonedetect/raw/c7ea46531444b600246fe651bc9feb66a7593be5/LICENCE.txt >> LICENSE
|
13
|
+
git add .
|
14
|
+
git commit -am "initial jstz-rails"
|
15
|
+
git remote add origin git@github.com:vanetten/jstz-rails.git
|
16
|
+
|
17
|
+
* modify **lib/gridster-rails/version.rb** to match gridster.js version
|
18
|
+
|
19
|
+
VERSION = "0.1.0.1"
|
20
|
+
|
21
|
+
* modify **lib/gridster-rails.rb** to subclass Rails::Engine
|
22
|
+
|
23
|
+
class Engine < ::Rails::Engine
|
24
|
+
end
|
25
|
+
|
26
|
+
* modify **gridster-rails.gemspec**
|
27
|
+
|
28
|
+
gem.description = "This gem provides jquery.gridster.js and jquery.gridster.css for your Rails 3 application."
|
29
|
+
gem.summary = "Use gridster with Rails 3"
|
30
|
+
gem.homepage = "http://rubygems.org/gems/gridster-rails"
|
31
|
+
gem.files = Dir["{lib,vendor}/**/*"] + ["LICENSE", "README.md"]
|
32
|
+
gem.add_dependency "railties", "~> 3.1"
|
33
|
+
|
34
|
+
* build
|
35
|
+
|
36
|
+
rake build
|
37
|
+
|
38
|
+
* release
|
39
|
+
|
40
|
+
rake release
|
41
|
+
|
42
|
+
## Installation
|
43
|
+
|
44
|
+
Add this line to your application's Gemfile:
|
45
|
+
|
46
|
+
gem 'jstz-rails'
|
47
|
+
|
48
|
+
And then execute:
|
49
|
+
|
50
|
+
$ bundle
|
51
|
+
|
52
|
+
Or install it yourself as:
|
53
|
+
|
54
|
+
$ gem install jstz-rails
|
55
|
+
|
56
|
+
## Usage
|
57
|
+
|
58
|
+
Add to **application.js**
|
59
|
+
|
60
|
+
//= require jstz.js
|
61
|
+
|
62
|
+
Add to **your.js** to write browser detected timezone to a cookie
|
63
|
+
|
64
|
+
document.cookie = 'time_zone='+jstz.determine().timezone.name()+';';
|
65
|
+
|
66
|
+
Add to **application_controller.rb** to set application's timezone from cookie
|
67
|
+
|
68
|
+
before_filter :set_timezone
|
69
|
+
private
|
70
|
+
def set_timezone
|
71
|
+
Time.zone = cookies["time_zone"]
|
72
|
+
end
|
73
|
+
|
74
|
+
Or add to view to set default from cookie (e.g. simple_form)
|
75
|
+
|
76
|
+
<%= f.input :time_zone, priority: /US/, :default => cookies["time_zone"] %>
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
1. Fork it
|
81
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
82
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
83
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
84
|
+
5. Create new Pull Request
|
85
|
+
|
86
|
+
# jstz.js appended README #
|
87
|
+
|
88
|
+
## Introduction
|
89
|
+
|
90
|
+
This script gives you the zone info key representing your device's time zone setting.
|
91
|
+
|
92
|
+
The return value is an [IANA zone info key][1] (aka the Olson time zone database).
|
93
|
+
|
94
|
+
The IANA timezone database is pretty much standard for most platforms (UNIX and Mac support it natively, and every programming language in the world either has native support or well maintained libraries that support it).
|
95
|
+
|
96
|
+
## Example Use
|
97
|
+
|
98
|
+
There is a [minified version in the repo][3] called `jstz.min.js`. Include it in your HTML document.
|
99
|
+
|
100
|
+
Invoke the script by calling
|
101
|
+
|
102
|
+
:::javascript
|
103
|
+
var tz = jstz.determine(); // Determines the time zone of the browser client
|
104
|
+
tz.name(); // Returns the name of the time zone eg "Europe/Berlin"
|
105
|
+
|
106
|
+
## Use Case
|
107
|
+
|
108
|
+
The script is useful if you do not want to disturb your users with questions about what time zone they are in. You can rely on this script to give you a key that is usable for server side datetime normalisations across time zones.
|
109
|
+
|
110
|
+
## Limitations
|
111
|
+
|
112
|
+
This script does not do geo-location, nor does it care very much about historical time zones.
|
113
|
+
|
114
|
+
So if you are unhappy with the time zone "Europe/Berlin" when the user is in fact in "Europe/Stockholm" - this script is not for you. (They are both identical in modern time).
|
115
|
+
|
116
|
+
Also, if it is important to you to know that in Europe/Simferopool (Ukraine) the UTC offset before 1924 was +2.67, sorry, this script will not help you.
|
117
|
+
|
118
|
+
Time zones are a screwed up thing, generally speaking, and the scope of this script is to solve problems concerning modern time zones, in this case from 2010 and forward.
|
119
|
+
|
120
|
+
## Demo
|
121
|
+
|
122
|
+
There is an updated demo running on: [http://pellepim.bitbucket.org/jstz/][2].
|
123
|
+
|
124
|
+
## Contribute?
|
125
|
+
|
126
|
+
If you want to contribute to the project (perhaps fix a bug, or reflect a change in time zone rules), please simply issue a Pull Request. Don't worry about [Grunt][4] builds etc, all you need to modify is the jstz.js file and I'll take care of the testing/minifying etc.
|
127
|
+
|
128
|
+
## Credits
|
129
|
+
|
130
|
+
Thanks to
|
131
|
+
|
132
|
+
- [Josh Fraser][5] for the original idea
|
133
|
+
- [Brian Donovan][6] for making jstz CommonJS compliant
|
134
|
+
- [Ilya Sedlovsky][7] for help with namespacing
|
135
|
+
|
136
|
+
Other contributors:
|
137
|
+
[Gilmore Davidson][8]
|
138
|
+
|
139
|
+
[1]: http://www.iana.org/time-zones
|
140
|
+
[2]: http://pellepim.bitbucket.org/jstz/
|
141
|
+
[3]: https://bitbucket.org/pellepim/jstimezonedetect/src
|
142
|
+
[4]: https://github.com/gruntjs/grunt
|
143
|
+
[5]: http://www.onlineaspect.com/about/
|
144
|
+
[6]: https://bitbucket.org/eventualbuddha
|
145
|
+
[7]: https://bitbucket.org/purebill
|
146
|
+
[8]: https://bitbucket.org/gdavidson
|
data/lib/jstz-rails.rb
ADDED
@@ -0,0 +1,334 @@
|
|
1
|
+
/*jslint undef: true */
|
2
|
+
/*global console, exports*/
|
3
|
+
|
4
|
+
(function(root) {
|
5
|
+
/**
|
6
|
+
* Namespace to hold all the code for timezone detection.
|
7
|
+
*/
|
8
|
+
var jstz = (function () {
|
9
|
+
'use strict';
|
10
|
+
var HEMISPHERE_SOUTH = 's',
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Gets the offset in minutes from UTC for a certain date.
|
14
|
+
* @param {Date} date
|
15
|
+
* @returns {Number}
|
16
|
+
*/
|
17
|
+
get_date_offset = function (date) {
|
18
|
+
var offset = -date.getTimezoneOffset();
|
19
|
+
return (offset !== null ? offset : 0);
|
20
|
+
},
|
21
|
+
|
22
|
+
get_date = function (year, month, date) {
|
23
|
+
var d = new Date();
|
24
|
+
if (year !== undefined) {
|
25
|
+
d.setFullYear(year);
|
26
|
+
}
|
27
|
+
d.setDate(date);
|
28
|
+
d.setMonth(month);
|
29
|
+
return d;
|
30
|
+
},
|
31
|
+
|
32
|
+
get_january_offset = function (year) {
|
33
|
+
return get_date_offset(get_date(year, 0 ,2));
|
34
|
+
},
|
35
|
+
|
36
|
+
get_june_offset = function (year) {
|
37
|
+
|
38
|
+
return get_date_offset(get_date(year, 5, 2));
|
39
|
+
},
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Private method.
|
43
|
+
* Checks whether a given date is in daylight savings time.
|
44
|
+
* If the date supplied is after august, we assume that we're checking
|
45
|
+
* for southern hemisphere DST.
|
46
|
+
* @param {Date} date
|
47
|
+
* @returns {Boolean}
|
48
|
+
*/
|
49
|
+
date_is_dst = function (date) {
|
50
|
+
var base_offset = ((date.getMonth() > 7 ? get_june_offset(date.getFullYear())
|
51
|
+
: get_january_offset(date.getFullYear()))),
|
52
|
+
date_offset = get_date_offset(date);
|
53
|
+
|
54
|
+
|
55
|
+
return (base_offset - date_offset) !== 0;
|
56
|
+
},
|
57
|
+
|
58
|
+
/**
|
59
|
+
* This function does some basic calculations to create information about
|
60
|
+
* the user's timezone.
|
61
|
+
*
|
62
|
+
* Returns a key that can be used to do lookups in jstz.olson.timezones.
|
63
|
+
*
|
64
|
+
* @returns {String}
|
65
|
+
*/
|
66
|
+
|
67
|
+
lookup_key = function () {
|
68
|
+
var january_offset = get_january_offset(),
|
69
|
+
june_offset = get_june_offset(),
|
70
|
+
diff = get_january_offset() - get_june_offset();
|
71
|
+
|
72
|
+
if (diff < 0) {
|
73
|
+
return january_offset + ",1";
|
74
|
+
} else if (diff > 0) {
|
75
|
+
return june_offset + ",1," + HEMISPHERE_SOUTH;
|
76
|
+
}
|
77
|
+
|
78
|
+
return january_offset + ",0";
|
79
|
+
},
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Uses get_timezone_info() to formulate a key to use in the olson.timezones dictionary.
|
83
|
+
*
|
84
|
+
* Returns a primitive object on the format:
|
85
|
+
* {'timezone': TimeZone, 'key' : 'the key used to find the TimeZone object'}
|
86
|
+
*
|
87
|
+
* @returns Object
|
88
|
+
*/
|
89
|
+
determine = function () {
|
90
|
+
var key = lookup_key();
|
91
|
+
return new jstz.TimeZone(jstz.olson.timezones[key]);
|
92
|
+
},
|
93
|
+
|
94
|
+
/**
|
95
|
+
* This object contains information on when daylight savings starts for
|
96
|
+
* different timezones.
|
97
|
+
*
|
98
|
+
* The list is short for a reason. Often we do not have to be very specific
|
99
|
+
* to single out the correct timezone. But when we do, this list comes in
|
100
|
+
* handy.
|
101
|
+
*
|
102
|
+
* Each value is a date denoting when daylight savings starts for that timezone.
|
103
|
+
*/
|
104
|
+
dst_start_for = function (tz_name) {
|
105
|
+
|
106
|
+
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 :)
|
107
|
+
dst_starts = {
|
108
|
+
'America/Denver': new Date(2011, 2, 13, 3, 0, 0, 0),
|
109
|
+
'America/Mazatlan': new Date(2011, 3, 3, 3, 0, 0, 0),
|
110
|
+
'America/Chicago': new Date(2011, 2, 13, 3, 0, 0, 0),
|
111
|
+
'America/Mexico_City': new Date(2011, 3, 3, 3, 0, 0, 0),
|
112
|
+
'America/Asuncion': new Date(2012, 9, 7, 3, 0, 0, 0),
|
113
|
+
'America/Santiago': new Date(2012, 9, 3, 3, 0, 0, 0),
|
114
|
+
'America/Campo_Grande': new Date(2012, 9, 21, 5, 0, 0, 0),
|
115
|
+
'America/Montevideo': new Date(2011, 9, 2, 3, 0, 0, 0),
|
116
|
+
'America/Sao_Paulo': new Date(2011, 9, 16, 5, 0, 0, 0),
|
117
|
+
'America/Los_Angeles': new Date(2011, 2, 13, 8, 0, 0, 0),
|
118
|
+
'America/Santa_Isabel': new Date(2011, 3, 5, 8, 0, 0, 0),
|
119
|
+
'America/Havana': new Date(2012, 2, 10, 2, 0, 0, 0),
|
120
|
+
'America/New_York': new Date(2012, 2, 10, 7, 0, 0, 0),
|
121
|
+
'Asia/Beirut': new Date(2011, 2, 27, 1, 0, 0, 0),
|
122
|
+
'Europe/Helsinki': new Date(2011, 2, 27, 4, 0, 0, 0),
|
123
|
+
'Europe/Istanbul': new Date(2011, 2, 28, 5, 0, 0, 0),
|
124
|
+
'Asia/Damascus': new Date(2011, 3, 1, 2, 0, 0, 0),
|
125
|
+
'Asia/Jerusalem': new Date(2011, 3, 1, 6, 0, 0, 0),
|
126
|
+
'Asia/Gaza': new Date(2009, 2, 28, 0, 30, 0, 0),
|
127
|
+
'Africa/Cairo': new Date(2009, 3, 25, 0, 30, 0, 0),
|
128
|
+
'Pacific/Auckland': new Date(2011, 8, 26, 7, 0, 0, 0),
|
129
|
+
'Pacific/Fiji': new Date(2010, 11, 29, 23, 0, 0, 0),
|
130
|
+
'America/Halifax': new Date(2011, 2, 13, 6, 0, 0, 0),
|
131
|
+
'America/Goose_Bay': new Date(2011, 2, 13, 2, 1, 0, 0),
|
132
|
+
'America/Miquelon': new Date(2011, 2, 13, 5, 0, 0, 0),
|
133
|
+
'America/Godthab': new Date(2011, 2, 27, 1, 0, 0, 0),
|
134
|
+
'Europe/Moscow': ru_pre_dst_change,
|
135
|
+
'Asia/Yekaterinburg': ru_pre_dst_change,
|
136
|
+
'Asia/Omsk': ru_pre_dst_change,
|
137
|
+
'Asia/Krasnoyarsk': ru_pre_dst_change,
|
138
|
+
'Asia/Irkutsk': ru_pre_dst_change,
|
139
|
+
'Asia/Yakutsk': ru_pre_dst_change,
|
140
|
+
'Asia/Vladivostok': ru_pre_dst_change,
|
141
|
+
'Asia/Kamchatka': ru_pre_dst_change,
|
142
|
+
'Europe/Minsk': ru_pre_dst_change,
|
143
|
+
'Australia/Perth': new Date(2008, 10, 1, 1, 0, 0, 0)
|
144
|
+
};
|
145
|
+
|
146
|
+
return dst_starts[tz_name];
|
147
|
+
};
|
148
|
+
|
149
|
+
return {
|
150
|
+
determine: determine,
|
151
|
+
date_is_dst: date_is_dst,
|
152
|
+
dst_start_for: dst_start_for
|
153
|
+
};
|
154
|
+
}());
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Simple object to perform ambiguity check and to return name of time zone.
|
158
|
+
*/
|
159
|
+
jstz.TimeZone = function (tz_name) {
|
160
|
+
'use strict';
|
161
|
+
/**
|
162
|
+
* The keys in this object are timezones that we know may be ambiguous after
|
163
|
+
* a preliminary scan through the olson_tz object.
|
164
|
+
*
|
165
|
+
* The array of timezones to compare must be in the order that daylight savings
|
166
|
+
* starts for the regions.
|
167
|
+
*
|
168
|
+
* @TODO: Once 2013 is upon us, remove Asia/Gaza from the Beirut ambiguity list,
|
169
|
+
* by then it should suffice that it lives in the Africa/Johannesburg check.
|
170
|
+
*/
|
171
|
+
var AMBIGUITIES = {
|
172
|
+
'America/Denver': ['America/Denver', 'America/Mazatlan'],
|
173
|
+
'America/Chicago': ['America/Chicago', 'America/Mexico_City'],
|
174
|
+
'America/Santiago': ['America/Santiago', 'America/Asuncion', 'America/Campo_Grande'],
|
175
|
+
'America/Montevideo': ['America/Montevideo', 'America/Sao_Paulo'],
|
176
|
+
'Asia/Beirut': ['Asia/Beirut', 'Europe/Helsinki', 'Europe/Istanbul', 'Asia/Damascus', 'Asia/Jerusalem', 'Asia/Gaza'],
|
177
|
+
'Pacific/Auckland': ['Pacific/Auckland', 'Pacific/Fiji'],
|
178
|
+
'America/Los_Angeles': ['America/Los_Angeles', 'America/Santa_Isabel'],
|
179
|
+
'America/New_York': ['America/Havana', 'America/New_York'],
|
180
|
+
'America/Halifax': ['America/Goose_Bay', 'America/Halifax'],
|
181
|
+
'America/Godthab': ['America/Miquelon', 'America/Godthab'],
|
182
|
+
'Asia/Dubai': ['Europe/Moscow'],
|
183
|
+
'Asia/Dhaka': ['Asia/Yekaterinburg'],
|
184
|
+
'Asia/Jakarta': ['Asia/Omsk'],
|
185
|
+
'Asia/Shanghai': ['Asia/Krasnoyarsk', 'Australia/Perth'],
|
186
|
+
'Asia/Tokyo': ['Asia/Irkutsk'],
|
187
|
+
'Australia/Brisbane': ['Asia/Yakutsk'],
|
188
|
+
'Pacific/Noumea': ['Asia/Vladivostok'],
|
189
|
+
'Pacific/Tarawa': ['Asia/Kamchatka'],
|
190
|
+
'Africa/Johannesburg': ['Asia/Gaza', 'Africa/Cairo'],
|
191
|
+
'Asia/Baghdad': ['Europe/Minsk']
|
192
|
+
},
|
193
|
+
|
194
|
+
timezone_name = tz_name,
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Checks if a timezone has possible ambiguities. I.e timezones that are similar.
|
198
|
+
*
|
199
|
+
* For example, if the preliminary scan determines that we're in America/Denver.
|
200
|
+
* We double check here that we're really there and not in America/Mazatlan.
|
201
|
+
*
|
202
|
+
* This is done by checking known dates for when daylight savings start for different
|
203
|
+
* timezones during 2010 and 2011.
|
204
|
+
*/
|
205
|
+
ambiguity_check = function () {
|
206
|
+
var ambiguity_list = AMBIGUITIES[timezone_name],
|
207
|
+
length = ambiguity_list.length,
|
208
|
+
i = 0,
|
209
|
+
tz = ambiguity_list[0];
|
210
|
+
|
211
|
+
for (; i < length; i += 1) {
|
212
|
+
tz = ambiguity_list[i];
|
213
|
+
|
214
|
+
if (jstz.date_is_dst(jstz.dst_start_for(tz))) {
|
215
|
+
timezone_name = tz;
|
216
|
+
return;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
},
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Checks if it is possible that the timezone is ambiguous.
|
223
|
+
*/
|
224
|
+
is_ambiguous = function () {
|
225
|
+
return typeof (AMBIGUITIES[timezone_name]) !== 'undefined';
|
226
|
+
};
|
227
|
+
|
228
|
+
if (is_ambiguous()) {
|
229
|
+
ambiguity_check();
|
230
|
+
}
|
231
|
+
|
232
|
+
return {
|
233
|
+
name: function () {
|
234
|
+
return timezone_name;
|
235
|
+
}
|
236
|
+
};
|
237
|
+
};
|
238
|
+
|
239
|
+
jstz.olson = {};
|
240
|
+
|
241
|
+
/*
|
242
|
+
* The keys in this dictionary are comma separated as such:
|
243
|
+
*
|
244
|
+
* First the offset compared to UTC time in minutes.
|
245
|
+
*
|
246
|
+
* Then a flag which is 0 if the timezone does not take daylight savings into account and 1 if it
|
247
|
+
* does.
|
248
|
+
*
|
249
|
+
* Thirdly an optional 's' signifies that the timezone is in the southern hemisphere,
|
250
|
+
* only interesting for timezones with DST.
|
251
|
+
*
|
252
|
+
* The mapped arrays is used for constructing the jstz.TimeZone object from within
|
253
|
+
* jstz.determine_timezone();
|
254
|
+
*/
|
255
|
+
jstz.olson.timezones = {
|
256
|
+
'-720,0' : 'Etc/GMT+12',
|
257
|
+
'-660,0' : 'Pacific/Pago_Pago',
|
258
|
+
'-600,1' : 'America/Adak',
|
259
|
+
'-600,0' : 'Pacific/Honolulu',
|
260
|
+
'-570,0' : 'Pacific/Marquesas',
|
261
|
+
'-540,0' : 'Pacific/Gambier',
|
262
|
+
'-540,1' : 'America/Anchorage',
|
263
|
+
'-480,1' : 'America/Los_Angeles',
|
264
|
+
'-480,0' : 'Pacific/Pitcairn',
|
265
|
+
'-420,0' : 'America/Phoenix',
|
266
|
+
'-420,1' : 'America/Denver',
|
267
|
+
'-360,0' : 'America/Guatemala',
|
268
|
+
'-360,1' : 'America/Chicago',
|
269
|
+
'-360,1,s' : 'Pacific/Easter',
|
270
|
+
'-300,0' : 'America/Bogota',
|
271
|
+
'-300,1' : 'America/New_York',
|
272
|
+
'-270,0' : 'America/Caracas',
|
273
|
+
'-240,1' : 'America/Halifax',
|
274
|
+
'-240,0' : 'America/Santo_Domingo',
|
275
|
+
'-240,1,s' : 'America/Santiago',
|
276
|
+
'-210,1' : 'America/St_Johns',
|
277
|
+
'-180,1' : 'America/Godthab',
|
278
|
+
'-180,0' : 'America/Argentina/Buenos_Aires',
|
279
|
+
'-180,1,s' : 'America/Montevideo',
|
280
|
+
'-120,0' : 'Etc/GMT+2',
|
281
|
+
'-120,1' : 'Etc/GMT+2',
|
282
|
+
'-60,1' : 'Atlantic/Azores',
|
283
|
+
'-60,0' : 'Atlantic/Cape_Verde',
|
284
|
+
'0,0' : 'Etc/UTC',
|
285
|
+
'0,1' : 'Europe/London',
|
286
|
+
'60,1' : 'Europe/Berlin',
|
287
|
+
'60,0' : 'Africa/Lagos',
|
288
|
+
'60,1,s' : 'Africa/Windhoek',
|
289
|
+
'120,1' : 'Asia/Beirut',
|
290
|
+
'120,0' : 'Africa/Johannesburg',
|
291
|
+
'180,0' : 'Asia/Baghdad',
|
292
|
+
'180,1' : 'Europe/Moscow',
|
293
|
+
'210,1' : 'Asia/Tehran',
|
294
|
+
'240,0' : 'Asia/Dubai',
|
295
|
+
'240,1' : 'Asia/Baku',
|
296
|
+
'270,0' : 'Asia/Kabul',
|
297
|
+
'300,1' : 'Asia/Yekaterinburg',
|
298
|
+
'300,0' : 'Asia/Karachi',
|
299
|
+
'330,0' : 'Asia/Kolkata',
|
300
|
+
'345,0' : 'Asia/Kathmandu',
|
301
|
+
'360,0' : 'Asia/Dhaka',
|
302
|
+
'360,1' : 'Asia/Omsk',
|
303
|
+
'390,0' : 'Asia/Rangoon',
|
304
|
+
'420,1' : 'Asia/Krasnoyarsk',
|
305
|
+
'420,0' : 'Asia/Jakarta',
|
306
|
+
'480,0' : 'Asia/Shanghai',
|
307
|
+
'480,1' : 'Asia/Irkutsk',
|
308
|
+
'525,0' : 'Australia/Eucla',
|
309
|
+
'525,1,s' : 'Australia/Eucla',
|
310
|
+
'540,1' : 'Asia/Yakutsk',
|
311
|
+
'540,0' : 'Asia/Tokyo',
|
312
|
+
'570,0' : 'Australia/Darwin',
|
313
|
+
'570,1,s' : 'Australia/Adelaide',
|
314
|
+
'600,0' : 'Australia/Brisbane',
|
315
|
+
'600,1' : 'Asia/Vladivostok',
|
316
|
+
'600,1,s' : 'Australia/Sydney',
|
317
|
+
'630,1,s' : 'Australia/Lord_Howe',
|
318
|
+
'660,1' : 'Asia/Kamchatka',
|
319
|
+
'660,0' : 'Pacific/Noumea',
|
320
|
+
'690,0' : 'Pacific/Norfolk',
|
321
|
+
'720,1,s' : 'Pacific/Auckland',
|
322
|
+
'720,0' : 'Pacific/Tarawa',
|
323
|
+
'765,1,s' : 'Pacific/Chatham',
|
324
|
+
'780,0' : 'Pacific/Tongatapu',
|
325
|
+
'780,1,s' : 'Pacific/Apia',
|
326
|
+
'840,0' : 'Pacific/Kiritimati'
|
327
|
+
};
|
328
|
+
|
329
|
+
if (typeof exports !== 'undefined') {
|
330
|
+
exports.jstz = jstz;
|
331
|
+
} else {
|
332
|
+
root.jstz = jstz;
|
333
|
+
}
|
334
|
+
})(this);
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jstz-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- William Van Etten
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-04 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.1'
|
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.1'
|
30
|
+
description: This gem provides jstz.js and for your Rails 3 application.
|
31
|
+
email:
|
32
|
+
- bill@bioteam.net
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- lib/jstz-rails/version.rb
|
38
|
+
- lib/jstz-rails.rb
|
39
|
+
- vendor/assets/javascripts/jstz.js
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
homepage: http://rubygems.org/gems/jstz-rails
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.8.24
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Use jstz with Rails 3
|
66
|
+
test_files: []
|