moment_timezone-rails 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/lib/moment_timezone/rails/version.rb +1 -1
- data/moment_timezone-rails.gemspec +2 -2
- data/vendor/assets/javascripts/moment-timezone.js +250 -460
- data/vendor/assets/javascripts/moment-timezone.min.js +6 -1
- metadata +15 -17
- data/app/assets/javascripts/moment-timezone-data.js +0 -7564
- data/vendor/assets/javascripts/moment-timezone.json +0 -7564
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34fb06044fcd232cebb6940b4e9d5ce0530b41db
|
4
|
+
data.tar.gz: cab067330843c1104899f723db40e86e4caaa31b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80bc732d49f06ca3d0c22a2f55f67bfad3b383624cb3b6095b80d77f619d378136189cd6985663a105ee9e96760d4cac4bc10a252a36ef73649e823adba569c0
|
7
|
+
data.tar.gz: b7cb6f1fc57c8d86b728a2ca7f134134733e8c722ae7c05ea1ac0b63dae57ba36e40cc57cead49645dfbd878dd91399acc8c311dfe11d8349a9208182177ed83
|
data/README.md
CHANGED
@@ -4,7 +4,13 @@
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
`momentjs-rails` need to be explicitly included in your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'momentjs-rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then add this line to your application's Gemfile:
|
8
14
|
|
9
15
|
```ruby
|
10
16
|
gem 'moment_timezone-rails'
|
@@ -26,12 +32,30 @@ $ gem install moment_timezone-rails
|
|
26
32
|
|
27
33
|
Add the following directives to `application.js`.
|
28
34
|
|
35
|
+
### For v0.0.4 and below
|
36
|
+
|
29
37
|
```js
|
30
38
|
//= require moment
|
31
39
|
//= require moment-timezone
|
32
40
|
//= require moment-timezone-data
|
33
41
|
```
|
34
42
|
|
43
|
+
### For v0.1.0
|
44
|
+
|
45
|
+
```js
|
46
|
+
//= require moment
|
47
|
+
|
48
|
+
// moment-timezone without timezone data
|
49
|
+
//= require moment-timezone
|
50
|
+
|
51
|
+
// moment-timezone with timezone data from 2010-2020
|
52
|
+
//= require moment-timezone-2010-2020
|
53
|
+
|
54
|
+
// moment-timezone all timezone data
|
55
|
+
//= require moment-timezone-all-years
|
56
|
+
|
57
|
+
```
|
58
|
+
|
35
59
|
## Contributing
|
36
60
|
|
37
61
|
1. Fork it
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "rails", "~> 3.2
|
21
|
+
spec.add_development_dependency "rails", "~> 3.2"
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "momentjs-rails", "~> 2.
|
23
|
+
spec.add_runtime_dependency "momentjs-rails", "~> 2.7"
|
24
24
|
end
|
@@ -1,540 +1,330 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
(function () {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
function
|
12
|
-
|
13
|
-
|
1
|
+
//! moment-timezone.js
|
2
|
+
//! version : 0.1.0
|
3
|
+
//! author : Tim Wood
|
4
|
+
//! license : MIT
|
5
|
+
//! github.com/moment/moment-timezone
|
6
|
+
|
7
|
+
(function (root, factory) {
|
8
|
+
"use strict";
|
9
|
+
|
10
|
+
/*global define*/
|
11
|
+
if (typeof define === 'function' && define.amd) {
|
12
|
+
define(['moment'], factory); // AMD
|
13
|
+
} else if (typeof exports === 'object') {
|
14
|
+
module.exports = factory(require('moment')); // Node
|
15
|
+
} else {
|
16
|
+
factory(root.moment); // Browser
|
17
|
+
}
|
18
|
+
}(this, function (moment) {
|
19
|
+
"use strict";
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
ruleSets = {},
|
18
|
-
zones = {},
|
19
|
-
zoneSets = {},
|
20
|
-
links = {},
|
21
|
+
// Do not load moment-timezone a second time.
|
22
|
+
if (moment.tz !== undefined) { return moment; }
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
var VERSION = "0.1.0",
|
25
|
+
zones = {},
|
26
|
+
links = {};
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
/************************************
|
29
|
+
Unpacking
|
30
|
+
************************************/
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
return;
|
32
|
+
function charCodeToInt(charCode) {
|
33
|
+
if (charCode > 96) {
|
34
|
+
return charCode - 87;
|
35
|
+
} else if (charCode > 64) {
|
36
|
+
return charCode - 29;
|
32
37
|
}
|
38
|
+
return charCode - 48;
|
39
|
+
}
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
function unpackBase60(string) {
|
42
|
+
var i = 0,
|
43
|
+
parts = string.split('.'),
|
44
|
+
whole = parts[0],
|
45
|
+
fractional = parts[1] || '',
|
46
|
+
multiplier = 1,
|
47
|
+
num,
|
48
|
+
out = 0,
|
49
|
+
sign = 1;
|
50
|
+
|
51
|
+
// handle negative numbers
|
52
|
+
if (string.charCodeAt(0) === 45) {
|
53
|
+
i = 1;
|
54
|
+
sign = -1;
|
44
55
|
}
|
45
56
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
function Rule (name, startYear, endYear, month, day, dayRule, time, timeRule, offset, letters) {
|
51
|
-
this.name = name;
|
52
|
-
this.startYear = +startYear;
|
53
|
-
this.endYear = +endYear;
|
54
|
-
this.month = +month;
|
55
|
-
this.day = +day;
|
56
|
-
this.dayRule = +dayRule;
|
57
|
-
this.time = parseMinutes(time);
|
58
|
-
this.timeRule = +timeRule;
|
59
|
-
this.offset = parseMinutes(offset);
|
60
|
-
this.letters = letters || '';
|
61
|
-
this.date = memoize(this.date);
|
62
|
-
this.weekdayAfter = memoize(this.weekdayAfter);
|
63
|
-
this.lastWeekday = memoize(this.lastWeekday);
|
57
|
+
// handle digits before the decimal
|
58
|
+
for (i; i < whole.length; i++) {
|
59
|
+
num = charCodeToInt(whole.charCodeAt(i));
|
60
|
+
out = 60 * out + num;
|
64
61
|
}
|
65
62
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
year = Math.min(Math.max(year, this.startYear), this.endYear);
|
73
|
-
return moment.utc([year, this.month, this.date(year), 0, this.time]);
|
74
|
-
},
|
75
|
-
|
76
|
-
date : function (year) {
|
77
|
-
if (this.dayRule === DAY_RULE_DAY_OF_MONTH) {
|
78
|
-
return this.day;
|
79
|
-
} else if (this.dayRule === DAY_RULE_LAST_WEEKDAY) {
|
80
|
-
return this.lastWeekday(year);
|
81
|
-
}
|
82
|
-
return this.weekdayAfter(year);
|
83
|
-
},
|
84
|
-
|
85
|
-
weekdayAfter : function (year) {
|
86
|
-
var day = this.day,
|
87
|
-
firstDayOfWeek = moment([year, this.month, 1]).day(),
|
88
|
-
output = this.dayRule + 1 - firstDayOfWeek;
|
89
|
-
|
90
|
-
while (output < day) {
|
91
|
-
output += 7;
|
92
|
-
}
|
93
|
-
|
94
|
-
return output;
|
95
|
-
},
|
96
|
-
|
97
|
-
lastWeekday : function (year) {
|
98
|
-
var day = this.day,
|
99
|
-
dow = day % 7,
|
100
|
-
lastDowOfMonth = moment([year, this.month + 1, 1]).day(),
|
101
|
-
daysInMonth = moment([year, this.month, 1]).daysInMonth(),
|
102
|
-
output = daysInMonth + (dow - (lastDowOfMonth - 1)) - (~~(day / 7) * 7);
|
103
|
-
|
104
|
-
if (dow >= lastDowOfMonth) {
|
105
|
-
output -= 7;
|
106
|
-
}
|
107
|
-
return output;
|
108
|
-
}
|
109
|
-
};
|
63
|
+
// handle digits after the decimal
|
64
|
+
for (i = 0; i < fractional.length; i++) {
|
65
|
+
multiplier = multiplier / 60;
|
66
|
+
num = charCodeToInt(fractional.charCodeAt(i));
|
67
|
+
out += num * multiplier;
|
68
|
+
}
|
110
69
|
|
111
|
-
|
112
|
-
|
113
|
-
************************************/
|
70
|
+
return out * sign;
|
71
|
+
}
|
114
72
|
|
115
|
-
|
116
|
-
|
117
|
-
|
73
|
+
function arrayToInt (array) {
|
74
|
+
for (var i = 0; i < array.length; i++) {
|
75
|
+
array[i] = unpackBase60(array[i]);
|
118
76
|
}
|
77
|
+
}
|
119
78
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
return false;
|
124
|
-
}
|
125
|
-
return Math.abs(other.start - this.start) < 86400000; // 24 * 60 * 60 * 1000
|
126
|
-
}
|
127
|
-
};
|
128
|
-
|
129
|
-
function sortRuleYears (a, b) {
|
130
|
-
if (a.isLast) {
|
131
|
-
return -1;
|
132
|
-
}
|
133
|
-
if (b.isLast) {
|
134
|
-
return 1;
|
135
|
-
}
|
136
|
-
return b.start - a.start;
|
79
|
+
function intToUntil (array, length) {
|
80
|
+
for (var i = 0; i < length; i++) {
|
81
|
+
array[i] = Math.round((array[i - 1] || 0) + (array[i] * 60000)); // minutes to milliseconds
|
137
82
|
}
|
138
83
|
|
139
|
-
|
140
|
-
|
141
|
-
|
84
|
+
array[length - 1] = Infinity;
|
85
|
+
}
|
86
|
+
|
87
|
+
function mapIndices (source, indices) {
|
88
|
+
var out = [], i;
|
142
89
|
|
143
|
-
|
144
|
-
|
145
|
-
this.rules = [];
|
146
|
-
this.lastYearRule = memoize(this.lastYearRule);
|
90
|
+
for (i = 0; i < indices.length; i++) {
|
91
|
+
out[i] = source[indices[i]];
|
147
92
|
}
|
148
93
|
|
149
|
-
|
150
|
-
|
151
|
-
this.rules.push(rule);
|
152
|
-
},
|
153
|
-
|
154
|
-
ruleYears : function (mom, lastZone) {
|
155
|
-
var i, j,
|
156
|
-
year = mom.year(),
|
157
|
-
rule,
|
158
|
-
lastZoneRule,
|
159
|
-
rules = [];
|
160
|
-
|
161
|
-
for (i = 0; i < this.rules.length; i++) {
|
162
|
-
rule = this.rules[i];
|
163
|
-
if (rule.contains(year)) {
|
164
|
-
rules.push(new RuleYear(year, rule));
|
165
|
-
} else if (rule.contains(year + 1)) {
|
166
|
-
rules.push(new RuleYear(year + 1, rule));
|
167
|
-
}
|
168
|
-
}
|
169
|
-
rules.push(new RuleYear(year - 1, this.lastYearRule(year - 1)));
|
94
|
+
return out;
|
95
|
+
}
|
170
96
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
}
|
97
|
+
function unpack (string) {
|
98
|
+
var data = string.split('|'),
|
99
|
+
offsets = data[2].split(' '),
|
100
|
+
indices = data[3].split(''),
|
101
|
+
untils = data[4].split(' ');
|
177
102
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
rule : function (mom, offset, lastZone) {
|
183
|
-
var rules = this.ruleYears(mom, lastZone),
|
184
|
-
lastOffset = 0,
|
185
|
-
rule,
|
186
|
-
lastZoneOffset,
|
187
|
-
lastZoneOffsetAbs,
|
188
|
-
lastRule,
|
189
|
-
i;
|
190
|
-
|
191
|
-
if (lastZone) {
|
192
|
-
lastZoneOffset = lastZone.offset + lastZone.lastRule().offset;
|
193
|
-
lastZoneOffsetAbs = Math.abs(lastZoneOffset) * 90000;
|
194
|
-
}
|
103
|
+
arrayToInt(offsets);
|
104
|
+
arrayToInt(indices);
|
105
|
+
arrayToInt(untils);
|
195
106
|
|
196
|
-
|
197
|
-
for (i = rules.length - 1; i > -1; i--) {
|
198
|
-
lastRule = rule;
|
199
|
-
rule = rules[i];
|
107
|
+
intToUntil(untils, indices.length);
|
200
108
|
|
201
|
-
|
202
|
-
|
203
|
-
|
109
|
+
return {
|
110
|
+
name : data[0],
|
111
|
+
abbrs : mapIndices(data[1].split(' '), indices),
|
112
|
+
offsets : mapIndices(offsets, indices),
|
113
|
+
untils : untils
|
114
|
+
};
|
115
|
+
}
|
204
116
|
|
205
|
-
|
206
|
-
|
207
|
-
|
117
|
+
/************************************
|
118
|
+
Zone object
|
119
|
+
************************************/
|
208
120
|
|
209
|
-
|
210
|
-
|
211
|
-
|
121
|
+
function Zone (packedString) {
|
122
|
+
var unpacked = unpack(packedString);
|
123
|
+
this.name = unpacked.name;
|
124
|
+
this.abbrs = unpacked.abbrs;
|
125
|
+
this.untils = unpacked.untils;
|
126
|
+
this.offsets = unpacked.offsets;
|
127
|
+
}
|
212
128
|
|
213
|
-
|
214
|
-
|
215
|
-
|
129
|
+
Zone.prototype = {
|
130
|
+
_index : function (timestamp) {
|
131
|
+
var target = +timestamp,
|
132
|
+
untils = this.untils,
|
133
|
+
i;
|
216
134
|
|
217
|
-
|
135
|
+
for (i = 0; i < untils.length; i++) {
|
136
|
+
if (target < untils[i]) {
|
137
|
+
return i;
|
218
138
|
}
|
139
|
+
}
|
140
|
+
},
|
219
141
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
}
|
142
|
+
parse : function (timestamp) {
|
143
|
+
var target = +timestamp,
|
144
|
+
offsets = this.offsets,
|
145
|
+
untils = this.untils,
|
146
|
+
i;
|
226
147
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
lastYearRule : function (year) {
|
231
|
-
var i,
|
232
|
-
rule,
|
233
|
-
start,
|
234
|
-
bestRule = defaultRule,
|
235
|
-
largest = -1e30;
|
236
|
-
|
237
|
-
for (i = 0; i < this.rules.length; i++) {
|
238
|
-
rule = this.rules[i];
|
239
|
-
if (year >= rule.startYear) {
|
240
|
-
start = rule.start(year);
|
241
|
-
if (start > largest) {
|
242
|
-
largest = start;
|
243
|
-
bestRule = rule;
|
244
|
-
}
|
245
|
-
}
|
148
|
+
for (i = 0; i < untils.length; i++) {
|
149
|
+
if (target < untils[i] - (offsets[i] * 60000)) {
|
150
|
+
return offsets[i];
|
246
151
|
}
|
247
|
-
|
248
|
-
return bestRule;
|
249
152
|
}
|
250
|
-
}
|
251
|
-
|
252
|
-
/************************************
|
253
|
-
Zone
|
254
|
-
************************************/
|
153
|
+
},
|
255
154
|
|
256
|
-
function
|
257
|
-
|
258
|
-
|
155
|
+
abbr : function (mom) {
|
156
|
+
return this.abbrs[this._index(mom)];
|
157
|
+
},
|
259
158
|
|
260
|
-
|
261
|
-
this.
|
262
|
-
this.ruleSet = ruleSet;
|
263
|
-
this.letters = letters;
|
264
|
-
this.lastRule = memoize(this.lastRule);
|
265
|
-
|
266
|
-
for (i = 0; i < untilArray.length; i++) {
|
267
|
-
untilArray[i] = +untilArray[i];
|
268
|
-
}
|
269
|
-
this.until = moment.utc(untilArray).subtract('m', parseMinutes(untilOffset));
|
159
|
+
offset : function (mom) {
|
160
|
+
return this.offsets[this._index(mom)];
|
270
161
|
}
|
162
|
+
};
|
271
163
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
},
|
164
|
+
/************************************
|
165
|
+
Global Methods
|
166
|
+
************************************/
|
276
167
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
format : function (rule) {
|
282
|
-
return this.letters.replace("%s", rule.letters);
|
283
|
-
}
|
284
|
-
};
|
168
|
+
function normalizeName (name) {
|
169
|
+
return (name || '').toLowerCase().replace(/\//g, '_');
|
170
|
+
}
|
285
171
|
|
286
|
-
|
287
|
-
|
288
|
-
************************************/
|
172
|
+
function addZone (packed) {
|
173
|
+
var i, zone;
|
289
174
|
|
290
|
-
|
291
|
-
|
175
|
+
if (typeof packed === "string") {
|
176
|
+
packed = [packed];
|
292
177
|
}
|
293
178
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
this.zones = [];
|
298
|
-
this.zoneAndRule = memoize(this.zoneAndRule, function (mom) {
|
299
|
-
return +mom;
|
300
|
-
});
|
179
|
+
for (i = 0; i < packed.length; i++) {
|
180
|
+
zone = new Zone(packed[i]);
|
181
|
+
zones[normalizeName(zone.name)] = zone;
|
301
182
|
}
|
183
|
+
}
|
302
184
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
zone,
|
307
|
-
lastZone;
|
308
|
-
|
309
|
-
mom = mom.clone().utc();
|
310
|
-
for (i = 0; i < this.zones.length; i++) {
|
311
|
-
zone = this.zones[i];
|
312
|
-
if (mom < zone.until) {
|
313
|
-
break;
|
314
|
-
}
|
315
|
-
lastZone = zone;
|
316
|
-
}
|
317
|
-
|
318
|
-
return [zone, zone.rule(mom, lastZone)];
|
319
|
-
},
|
320
|
-
|
321
|
-
add : function (zone) {
|
322
|
-
this.zones.push(zone);
|
323
|
-
this.zones.sort(sortZones);
|
324
|
-
},
|
185
|
+
function getZone (name) {
|
186
|
+
name = normalizeName(name);
|
187
|
+
var linkName = links[name];
|
325
188
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
},
|
189
|
+
if (linkName && zones[linkName]) {
|
190
|
+
name = linkName;
|
191
|
+
}
|
330
192
|
|
331
|
-
|
332
|
-
|
333
|
-
return -(zoneAndRule[0].offset + zoneAndRule[1].offset);
|
334
|
-
}
|
335
|
-
};
|
193
|
+
return zones[name] || null;
|
194
|
+
}
|
336
195
|
|
337
|
-
|
338
|
-
|
339
|
-
************************************/
|
340
|
-
|
341
|
-
function memoize (fn, keyFn) {
|
342
|
-
var cache = {};
|
343
|
-
return function (first) {
|
344
|
-
var key = keyFn ? keyFn.apply(this, arguments) : first;
|
345
|
-
return key in cache ?
|
346
|
-
cache[key] :
|
347
|
-
(cache[key] = fn.apply(this, arguments));
|
348
|
-
};
|
349
|
-
}
|
196
|
+
function getNames () {
|
197
|
+
var i, out = [];
|
350
198
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
rule = rules[i];
|
355
|
-
for (j = 0; j < rule.length; j++) {
|
356
|
-
addRule(i + '\t' + rule[j]);
|
357
|
-
}
|
199
|
+
for (i in zones) {
|
200
|
+
if (zones.hasOwnProperty(i) && zones[i]) {
|
201
|
+
out.push(zones[i].name);
|
358
202
|
}
|
359
203
|
}
|
360
204
|
|
361
|
-
|
362
|
-
|
363
|
-
if (rules[ruleString]) {
|
364
|
-
return rules[ruleString];
|
365
|
-
}
|
366
|
-
|
367
|
-
var p = ruleString.split(/\s/),
|
368
|
-
name = normalizeName(p[0]),
|
369
|
-
rule = new Rule(name, p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10]);
|
370
|
-
|
371
|
-
// cache the rule so we don't add it again
|
372
|
-
rules[ruleString] = rule;
|
205
|
+
return out.sort();
|
206
|
+
}
|
373
207
|
|
374
|
-
|
375
|
-
|
208
|
+
function addLink (aliases) {
|
209
|
+
var i, alias;
|
376
210
|
|
377
|
-
|
211
|
+
if (typeof aliases === "string") {
|
212
|
+
aliases = [aliases];
|
378
213
|
}
|
379
214
|
|
380
|
-
|
381
|
-
|
215
|
+
for (i = 0; i < aliases.length; i++) {
|
216
|
+
alias = normalizeName(aliases[i]).split('|');
|
217
|
+
links[alias[0]] = alias[1];
|
218
|
+
links[alias[1]] = alias[0];
|
382
219
|
}
|
220
|
+
}
|
383
221
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
addZone(i + '\t' + zone[j]);
|
390
|
-
}
|
391
|
-
}
|
392
|
-
}
|
222
|
+
function loadData (data) {
|
223
|
+
addZone(data.zones);
|
224
|
+
addLink(data.links);
|
225
|
+
tz.dataVersion = data.version;
|
226
|
+
}
|
393
227
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
228
|
+
function zoneExists (name) {
|
229
|
+
if (!zoneExists.didShowError) {
|
230
|
+
zoneExists.didShowError = true;
|
231
|
+
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
232
|
+
console.error("moment.tz.zoneExists('" + name + "') has been deprecated in favor of !moment.tz.zone('" + name + "')");
|
398
233
|
}
|
399
234
|
}
|
235
|
+
return !!getZone(name);
|
236
|
+
}
|
400
237
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
return zones[zoneString];
|
405
|
-
}
|
406
|
-
|
407
|
-
var p = zoneString.split(/\s/),
|
408
|
-
name = normalizeName(p[0]),
|
409
|
-
zone = new Zone(name, p[1], getRuleSet(p[2]), p[3], p[4], p[5]);
|
238
|
+
function needsOffset (m) {
|
239
|
+
return !!(m._a && (m._tzm === undefined));
|
240
|
+
}
|
410
241
|
|
411
|
-
|
412
|
-
|
242
|
+
/************************************
|
243
|
+
moment.tz namespace
|
244
|
+
************************************/
|
413
245
|
|
414
|
-
|
415
|
-
|
246
|
+
function tz () {
|
247
|
+
var args = Array.prototype.slice.call(arguments, 0, -1),
|
248
|
+
name = arguments[arguments.length - 1],
|
249
|
+
zone = getZone(name),
|
250
|
+
out = moment.utc.apply(null, args);
|
416
251
|
|
417
|
-
|
252
|
+
if (zone && needsOffset(out)) {
|
253
|
+
out.add('minutes', zone.parse(out));
|
418
254
|
}
|
419
255
|
|
420
|
-
|
421
|
-
name = normalizeName(name);
|
422
|
-
if (!ruleSets[name]) {
|
423
|
-
ruleSets[name] = new RuleSet(name);
|
424
|
-
}
|
425
|
-
return ruleSets[name];
|
426
|
-
}
|
256
|
+
out.tz(name);
|
427
257
|
|
428
|
-
|
429
|
-
|
430
|
-
if (links[machineName]) {
|
431
|
-
machineName = links[machineName];
|
432
|
-
}
|
433
|
-
if (!zoneSets[machineName]) {
|
434
|
-
zoneSets[machineName] = new ZoneSet(name);
|
435
|
-
}
|
436
|
-
return zoneSets[machineName];
|
437
|
-
}
|
438
|
-
|
439
|
-
function add (data) {
|
440
|
-
if (!data) {
|
441
|
-
return;
|
442
|
-
}
|
443
|
-
if (data.zones) {
|
444
|
-
addZones(data.zones);
|
445
|
-
}
|
446
|
-
if (data.rules) {
|
447
|
-
addRules(data.rules);
|
448
|
-
}
|
449
|
-
if (data.links) {
|
450
|
-
addLinks(data.links);
|
451
|
-
}
|
452
|
-
}
|
453
|
-
|
454
|
-
// overwrite moment.updateOffset
|
455
|
-
moment.updateOffset = function (mom, keepTime) {
|
456
|
-
var offset;
|
457
|
-
if (mom._z) {
|
458
|
-
offset = mom._z.offset(mom);
|
459
|
-
if (Math.abs(offset) < 16) {
|
460
|
-
offset = offset / 60;
|
461
|
-
}
|
462
|
-
mom.zone(offset, keepTime);
|
463
|
-
}
|
464
|
-
};
|
258
|
+
return out;
|
259
|
+
}
|
465
260
|
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
261
|
+
tz.version = VERSION;
|
262
|
+
tz.dataVersion = '';
|
263
|
+
tz._zones = zones;
|
264
|
+
tz._links = links;
|
265
|
+
tz.add = addZone;
|
266
|
+
tz.link = addLink;
|
267
|
+
tz.load = loadData;
|
268
|
+
tz.zone = getZone;
|
269
|
+
tz.zoneExists = zoneExists; // deprecated in 0.1.0
|
270
|
+
tz.names = getNames;
|
271
|
+
tz.Zone = Zone;
|
272
|
+
tz.unpack = unpack;
|
273
|
+
tz.unpackBase60 = unpackBase60;
|
274
|
+
tz.needsOffset = needsOffset;
|
275
|
+
|
276
|
+
/************************************
|
277
|
+
Interface with Moment.js
|
278
|
+
************************************/
|
279
|
+
|
280
|
+
var fn = moment.fn;
|
281
|
+
|
282
|
+
moment.tz = tz;
|
283
|
+
|
284
|
+
moment.updateOffset = function (mom, keepTime) {
|
285
|
+
var offset;
|
286
|
+
if (mom._z) {
|
287
|
+
offset = mom._z.offset(mom);
|
288
|
+
if (Math.abs(offset) < 16) {
|
289
|
+
offset = offset / 60;
|
471
290
|
}
|
472
|
-
|
291
|
+
mom.zone(offset, keepTime);
|
473
292
|
}
|
293
|
+
};
|
474
294
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
if (this._z) {
|
479
|
-
moment.updateOffset(this);
|
480
|
-
}
|
481
|
-
return this;
|
482
|
-
}
|
483
|
-
if (this._z) {
|
484
|
-
return this._z.displayName;
|
485
|
-
}
|
486
|
-
};
|
487
|
-
|
488
|
-
moment.fn.zoneName = function () {
|
295
|
+
fn.tz = function (name) {
|
296
|
+
if (name) {
|
297
|
+
this._z = getZone(name);
|
489
298
|
if (this._z) {
|
490
|
-
|
299
|
+
moment.updateOffset(this);
|
491
300
|
}
|
492
|
-
return
|
493
|
-
}
|
301
|
+
return this;
|
302
|
+
}
|
303
|
+
if (this._z) { return this._z.name; }
|
304
|
+
};
|
494
305
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
return oldZoneAbbr.call(this);
|
306
|
+
function abbrWrap (old) {
|
307
|
+
return function () {
|
308
|
+
if (this._z) { return this._z.abbr(this); }
|
309
|
+
return old.call(this);
|
500
310
|
};
|
311
|
+
}
|
501
312
|
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
var args = [], i, len = arguments.length - 1;
|
507
|
-
for (i = 0; i < len; i++) {
|
508
|
-
args[i] = arguments[i];
|
509
|
-
}
|
510
|
-
var m = moment.apply(null, args);
|
511
|
-
var preTzOffset = m.zone();
|
512
|
-
m.tz(arguments[len]);
|
513
|
-
return m.add('minutes', m.zone() - preTzOffset);
|
313
|
+
function resetZoneWrap (old) {
|
314
|
+
return function () {
|
315
|
+
this._z = null;
|
316
|
+
return old.call(this);
|
514
317
|
};
|
318
|
+
}
|
515
319
|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
moment.tz.zones = getZoneSets;
|
520
|
-
|
521
|
-
moment.tz.version = VERSION;
|
522
|
-
|
523
|
-
moment.tz.zoneExists = function (name) {
|
524
|
-
return getZoneSet(name).zones.length > 0;
|
525
|
-
};
|
320
|
+
fn.zoneName = abbrWrap(fn.zoneName);
|
321
|
+
fn.zoneAbbr = abbrWrap(fn.zoneAbbr);
|
322
|
+
fn.utc = resetZoneWrap(fn.utc);
|
526
323
|
|
527
|
-
|
528
|
-
|
324
|
+
// Cloning a moment should include the _z property.
|
325
|
+
moment.momentProperties._z = null;
|
529
326
|
|
530
|
-
|
531
|
-
}
|
327
|
+
// INJECT DATA
|
532
328
|
|
533
|
-
|
534
|
-
|
535
|
-
} else if (typeof module !== 'undefined') {
|
536
|
-
module.exports = onload(require('moment'));
|
537
|
-
} else if (typeof window !== "undefined" && window.moment) {
|
538
|
-
onload(window.moment);
|
539
|
-
}
|
540
|
-
}).apply(this);
|
329
|
+
return moment;
|
330
|
+
}));
|