local_time 2.1.0 → 3.0.3

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +50 -10
  4. data/app/assets/javascripts/local-time.es2017-esm.js +1 -0
  5. data/app/assets/javascripts/local-time.es2017-umd.js +1 -0
  6. data/app/helpers/local_time_helper.rb +72 -21
  7. data/lib/local_time/version.rb +3 -0
  8. data/test/helpers/local_time_helper_test.rb +60 -31
  9. data/test/javascripts/builds/index.js +26626 -0
  10. data/test/javascripts/fixtures/index.html +20 -0
  11. data/test/javascripts/fixtures/time_zone_check.html +20 -0
  12. data/test/javascripts/server.mjs +41 -0
  13. data/test/javascripts/src/format24_test.js +109 -0
  14. data/test/javascripts/src/i18n_test.js +55 -0
  15. data/test/javascripts/src/index.js +10 -0
  16. data/test/javascripts/src/local_time_test.js +54 -0
  17. data/test/javascripts/src/relative_date_test.js +121 -0
  18. data/test/javascripts/src/strftime_test.js +151 -0
  19. data/test/javascripts/src/test_helpers.js +66 -0
  20. data/test/javascripts/src/time_ago_test.js +72 -0
  21. data/test/javascripts/vendor/moment.js +5684 -2
  22. data/test/javascripts/vendor/sinon.js +20485 -0
  23. metadata +81 -28
  24. data/app/assets/javascripts/local-time.js +0 -1
  25. data/test/javascripts/fixtures/body.html +0 -8
  26. data/test/javascripts/src/i18n_test.coffee +0 -47
  27. data/test/javascripts/src/local_time_test.coffee +0 -37
  28. data/test/javascripts/src/relative_date_test.coffee +0 -89
  29. data/test/javascripts/src/strftime_test.coffee +0 -54
  30. data/test/javascripts/src/test.coffee +0 -43
  31. data/test/javascripts/src/time_ago_test.coffee +0 -56
  32. data/test/javascripts/vendor/sinon-timers.js +0 -385
@@ -1,385 +0,0 @@
1
- /**
2
- * Sinon.JS 1.7.1, 2013/05/07
3
- *
4
- * @author Christian Johansen (christian@cjohansen.no)
5
- * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
6
- *
7
- * (The BSD License)
8
- *
9
- * Copyright (c) 2010-2013, Christian Johansen, christian@cjohansen.no
10
- * All rights reserved.
11
- *
12
- * Redistribution and use in source and binary forms, with or without modification,
13
- * are permitted provided that the following conditions are met:
14
- *
15
- * * Redistributions of source code must retain the above copyright notice,
16
- * this list of conditions and the following disclaimer.
17
- * * Redistributions in binary form must reproduce the above copyright notice,
18
- * this list of conditions and the following disclaimer in the documentation
19
- * and/or other materials provided with the distribution.
20
- * * Neither the name of Christian Johansen nor the names of his contributors
21
- * may be used to endorse or promote products derived from this software
22
- * without specific prior written permission.
23
- *
24
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- */
35
-
36
- /*jslint eqeqeq: false, plusplus: false, evil: true, onevar: false, browser: true, forin: false*/
37
- /*global module, require, window*/
38
- /**
39
- * Fake timer API
40
- * setTimeout
41
- * setInterval
42
- * clearTimeout
43
- * clearInterval
44
- * tick
45
- * reset
46
- * Date
47
- *
48
- * Inspired by jsUnitMockTimeOut from JsUnit
49
- *
50
- * @author Christian Johansen (christian@cjohansen.no)
51
- * @license BSD
52
- *
53
- * Copyright (c) 2010-2013 Christian Johansen
54
- */
55
-
56
- if (typeof sinon == "undefined") {
57
- var sinon = {};
58
- }
59
-
60
- (function (global) {
61
- var id = 1;
62
-
63
- function addTimer(args, recurring) {
64
- if (args.length === 0) {
65
- throw new Error("Function requires at least 1 parameter");
66
- }
67
-
68
- var toId = id++;
69
- var delay = args[1] || 0;
70
-
71
- if (!this.timeouts) {
72
- this.timeouts = {};
73
- }
74
-
75
- this.timeouts[toId] = {
76
- id: toId,
77
- func: args[0],
78
- callAt: this.now + delay,
79
- invokeArgs: Array.prototype.slice.call(args, 2)
80
- };
81
-
82
- if (recurring === true) {
83
- this.timeouts[toId].interval = delay;
84
- }
85
-
86
- return toId;
87
- }
88
-
89
- function parseTime(str) {
90
- if (!str) {
91
- return 0;
92
- }
93
-
94
- var strings = str.split(":");
95
- var l = strings.length, i = l;
96
- var ms = 0, parsed;
97
-
98
- if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
99
- throw new Error("tick only understands numbers and 'h:m:s'");
100
- }
101
-
102
- while (i--) {
103
- parsed = parseInt(strings[i], 10);
104
-
105
- if (parsed >= 60) {
106
- throw new Error("Invalid time " + str);
107
- }
108
-
109
- ms += parsed * Math.pow(60, (l - i - 1));
110
- }
111
-
112
- return ms * 1000;
113
- }
114
-
115
- function createObject(object) {
116
- var newObject;
117
-
118
- if (Object.create) {
119
- newObject = Object.create(object);
120
- } else {
121
- var F = function () {};
122
- F.prototype = object;
123
- newObject = new F();
124
- }
125
-
126
- newObject.Date.clock = newObject;
127
- return newObject;
128
- }
129
-
130
- sinon.clock = {
131
- now: 0,
132
-
133
- create: function create(now) {
134
- var clock = createObject(this);
135
-
136
- if (typeof now == "number") {
137
- clock.now = now;
138
- }
139
-
140
- if (!!now && typeof now == "object") {
141
- throw new TypeError("now should be milliseconds since UNIX epoch");
142
- }
143
-
144
- return clock;
145
- },
146
-
147
- setTimeout: function setTimeout(callback, timeout) {
148
- return addTimer.call(this, arguments, false);
149
- },
150
-
151
- clearTimeout: function clearTimeout(timerId) {
152
- if (!this.timeouts) {
153
- this.timeouts = [];
154
- }
155
-
156
- if (timerId in this.timeouts) {
157
- delete this.timeouts[timerId];
158
- }
159
- },
160
-
161
- setInterval: function setInterval(callback, timeout) {
162
- return addTimer.call(this, arguments, true);
163
- },
164
-
165
- clearInterval: function clearInterval(timerId) {
166
- this.clearTimeout(timerId);
167
- },
168
-
169
- tick: function tick(ms) {
170
- ms = typeof ms == "number" ? ms : parseTime(ms);
171
- var tickFrom = this.now, tickTo = this.now + ms, previous = this.now;
172
- var timer = this.firstTimerInRange(tickFrom, tickTo);
173
-
174
- var firstException;
175
- while (timer && tickFrom <= tickTo) {
176
- if (this.timeouts[timer.id]) {
177
- tickFrom = this.now = timer.callAt;
178
- try {
179
- this.callTimer(timer);
180
- } catch (e) {
181
- firstException = firstException || e;
182
- }
183
- }
184
-
185
- timer = this.firstTimerInRange(previous, tickTo);
186
- previous = tickFrom;
187
- }
188
-
189
- this.now = tickTo;
190
-
191
- if (firstException) {
192
- throw firstException;
193
- }
194
-
195
- return this.now;
196
- },
197
-
198
- firstTimerInRange: function (from, to) {
199
- var timer, smallest, originalTimer;
200
-
201
- for (var id in this.timeouts) {
202
- if (this.timeouts.hasOwnProperty(id)) {
203
- if (this.timeouts[id].callAt < from || this.timeouts[id].callAt > to) {
204
- continue;
205
- }
206
-
207
- if (!smallest || this.timeouts[id].callAt < smallest) {
208
- originalTimer = this.timeouts[id];
209
- smallest = this.timeouts[id].callAt;
210
-
211
- timer = {
212
- func: this.timeouts[id].func,
213
- callAt: this.timeouts[id].callAt,
214
- interval: this.timeouts[id].interval,
215
- id: this.timeouts[id].id,
216
- invokeArgs: this.timeouts[id].invokeArgs
217
- };
218
- }
219
- }
220
- }
221
-
222
- return timer || null;
223
- },
224
-
225
- callTimer: function (timer) {
226
- if (typeof timer.interval == "number") {
227
- this.timeouts[timer.id].callAt += timer.interval;
228
- } else {
229
- delete this.timeouts[timer.id];
230
- }
231
-
232
- try {
233
- if (typeof timer.func == "function") {
234
- timer.func.apply(null, timer.invokeArgs);
235
- } else {
236
- eval(timer.func);
237
- }
238
- } catch (e) {
239
- var exception = e;
240
- }
241
-
242
- if (!this.timeouts[timer.id]) {
243
- if (exception) {
244
- throw exception;
245
- }
246
- return;
247
- }
248
-
249
- if (exception) {
250
- throw exception;
251
- }
252
- },
253
-
254
- reset: function reset() {
255
- this.timeouts = {};
256
- },
257
-
258
- Date: (function () {
259
- var NativeDate = Date;
260
-
261
- function ClockDate(year, month, date, hour, minute, second, ms) {
262
- // Defensive and verbose to avoid potential harm in passing
263
- // explicit undefined when user does not pass argument
264
- switch (arguments.length) {
265
- case 0:
266
- return new NativeDate(ClockDate.clock.now);
267
- case 1:
268
- return new NativeDate(year);
269
- case 2:
270
- return new NativeDate(year, month);
271
- case 3:
272
- return new NativeDate(year, month, date);
273
- case 4:
274
- return new NativeDate(year, month, date, hour);
275
- case 5:
276
- return new NativeDate(year, month, date, hour, minute);
277
- case 6:
278
- return new NativeDate(year, month, date, hour, minute, second);
279
- default:
280
- return new NativeDate(year, month, date, hour, minute, second, ms);
281
- }
282
- }
283
-
284
- return mirrorDateProperties(ClockDate, NativeDate);
285
- }())
286
- };
287
-
288
- function mirrorDateProperties(target, source) {
289
- if (source.now) {
290
- target.now = function now() {
291
- return target.clock.now;
292
- };
293
- } else {
294
- delete target.now;
295
- }
296
-
297
- if (source.toSource) {
298
- target.toSource = function toSource() {
299
- return source.toSource();
300
- };
301
- } else {
302
- delete target.toSource;
303
- }
304
-
305
- target.toString = function toString() {
306
- return source.toString();
307
- };
308
-
309
- target.prototype = source.prototype;
310
- target.parse = source.parse;
311
- target.UTC = source.UTC;
312
- target.prototype.toUTCString = source.prototype.toUTCString;
313
- return target;
314
- }
315
-
316
- var methods = ["Date", "setTimeout", "setInterval",
317
- "clearTimeout", "clearInterval"];
318
-
319
- function restore() {
320
- var method;
321
-
322
- for (var i = 0, l = this.methods.length; i < l; i++) {
323
- method = this.methods[i];
324
- if (global[method].hadOwnProperty) {
325
- global[method] = this["_" + method];
326
- } else {
327
- delete global[method];
328
- }
329
- }
330
-
331
- // Prevent multiple executions which will completely remove these props
332
- this.methods = [];
333
- }
334
-
335
- function stubGlobal(method, clock) {
336
- clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(global, method);
337
- clock["_" + method] = global[method];
338
-
339
- if (method == "Date") {
340
- var date = mirrorDateProperties(clock[method], global[method]);
341
- global[method] = date;
342
- } else {
343
- global[method] = function () {
344
- return clock[method].apply(clock, arguments);
345
- };
346
-
347
- for (var prop in clock[method]) {
348
- if (clock[method].hasOwnProperty(prop)) {
349
- global[method][prop] = clock[method][prop];
350
- }
351
- }
352
- }
353
-
354
- global[method].clock = clock;
355
- }
356
-
357
- sinon.useFakeTimers = function useFakeTimers(now) {
358
- var clock = sinon.clock.create(now);
359
- clock.restore = restore;
360
- clock.methods = Array.prototype.slice.call(arguments,
361
- typeof now == "number" ? 1 : 0);
362
-
363
- if (clock.methods.length === 0) {
364
- clock.methods = methods;
365
- }
366
-
367
- for (var i = 0, l = clock.methods.length; i < l; i++) {
368
- stubGlobal(clock.methods[i], clock);
369
- }
370
-
371
- return clock;
372
- };
373
- }(typeof global != "undefined" && typeof global !== "function" ? global : this));
374
-
375
- sinon.timers = {
376
- setTimeout: setTimeout,
377
- clearTimeout: clearTimeout,
378
- setInterval: setInterval,
379
- clearInterval: clearInterval,
380
- Date: Date
381
- };
382
-
383
- if (typeof module == "object" && typeof require == "function") {
384
- module.exports = sinon;
385
- }