momentjs-rails 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/changelog.md +5 -0
- data/vendor/assets/javascripts/moment.js +46 -20
- metadata +5 -4
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Add the following directive to your Javascript manifest file (application.js):
|
|
20
20
|
|
21
21
|
## Versioning
|
22
22
|
|
23
|
-
momentjs-rails 1.
|
23
|
+
momentjs-rails 1.4.0 == Moment.js 1.4.0
|
24
24
|
|
25
25
|
Every attempt is made to mirror the currently shipping Momentum.js version number wherever possible.
|
26
26
|
The major and minor version numbers will always represent the Momentum.js version, but the patch level
|
data/changelog.md
ADDED
@@ -3,7 +3,9 @@
|
|
3
3
|
// (c) 2011 Tim Wood
|
4
4
|
// Moment.js is freely distributable under the terms of the MIT license.
|
5
5
|
//
|
6
|
-
// Version 1.
|
6
|
+
// Version 1.4.0
|
7
|
+
|
8
|
+
/*global define:false */
|
7
9
|
|
8
10
|
(function (Date, undefined) {
|
9
11
|
|
@@ -13,13 +15,14 @@
|
|
13
15
|
hasModule = (typeof module !== 'undefined'),
|
14
16
|
paramsToParse = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|'),
|
15
17
|
i,
|
18
|
+
jsonRegex = /^\/?Date\((\d+)/i,
|
16
19
|
charactersToReplace = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g,
|
17
20
|
nonuppercaseLetters = /[^A-Z]/g,
|
18
21
|
timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
|
19
22
|
tokenCharacters = /(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g,
|
20
23
|
inputCharacters = /(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi,
|
21
24
|
timezoneParseRegex = /([\+\-]|\d\d)/gi,
|
22
|
-
VERSION = "1.
|
25
|
+
VERSION = "1.4.0",
|
23
26
|
shortcuts = 'Month|Date|Hours|Minutes|Seconds|Milliseconds'.split('|');
|
24
27
|
|
25
28
|
// Moment prototype object
|
@@ -43,7 +46,7 @@
|
|
43
46
|
input = isString ? {} : _input,
|
44
47
|
ms, d, M, currentDate;
|
45
48
|
if (isString && val) {
|
46
|
-
input[_input] = val;
|
49
|
+
input[_input] = +val;
|
47
50
|
}
|
48
51
|
ms = (input.ms || input.milliseconds || 0) +
|
49
52
|
(input.s || input.seconds || 0) * 1e3 + // 1000
|
@@ -91,7 +94,7 @@
|
|
91
94
|
currentHours = m.hours(),
|
92
95
|
currentMinutes = m.minutes(),
|
93
96
|
currentSeconds = m.seconds(),
|
94
|
-
currentZone = m.zone(),
|
97
|
+
currentZone = -m.zone(),
|
95
98
|
ordinal = moment.ordinal,
|
96
99
|
meridiem = moment.meridiem;
|
97
100
|
// check if the character is a format
|
@@ -287,15 +290,15 @@
|
|
287
290
|
// fall through to ZZ
|
288
291
|
case 'ZZ' :
|
289
292
|
isUsingUTC = true;
|
290
|
-
a = input.match(timezoneParseRegex);
|
291
|
-
if (a[1]) {
|
293
|
+
a = (input || '').match(timezoneParseRegex);
|
294
|
+
if (a && a[1]) {
|
292
295
|
timezoneHours = ~~a[1];
|
293
296
|
}
|
294
|
-
if (a[2]) {
|
297
|
+
if (a && a[2]) {
|
295
298
|
timezoneMinutes = ~~a[2];
|
296
299
|
}
|
297
300
|
// reverse offsets
|
298
|
-
if (a[0] === '
|
301
|
+
if (a && a[0] === '+') {
|
299
302
|
timezoneHours = -timezoneHours;
|
300
303
|
timezoneMinutes = -timezoneMinutes;
|
301
304
|
}
|
@@ -358,8 +361,9 @@
|
|
358
361
|
if (input === null) {
|
359
362
|
return null;
|
360
363
|
}
|
361
|
-
var date
|
362
|
-
|
364
|
+
var date,
|
365
|
+
matched;
|
366
|
+
// parse Moment object
|
363
367
|
if (input && input._d instanceof Date) {
|
364
368
|
date = new Date(+input._d);
|
365
369
|
// parse string and format
|
@@ -369,9 +373,11 @@
|
|
369
373
|
} else {
|
370
374
|
date = makeDateFromStringAndFormat(input, format);
|
371
375
|
}
|
372
|
-
//
|
376
|
+
// evaluate it as a JSON-encoded date
|
373
377
|
} else {
|
378
|
+
matched = jsonRegex.exec(input);
|
374
379
|
date = input === undefined ? new Date() :
|
380
|
+
matched ? new Date(+matched[1]) :
|
375
381
|
input instanceof Date ? input :
|
376
382
|
isArray(input) ? dateFromArray(input) :
|
377
383
|
new Date(input);
|
@@ -526,13 +532,14 @@
|
|
526
532
|
|
527
533
|
diff : function (input, val, asFloat) {
|
528
534
|
var inputMoment = moment(input),
|
529
|
-
|
535
|
+
zoneDiff = (this.zone() - inputMoment.zone()) * 6e4,
|
536
|
+
diff = this._d - inputMoment._d - zoneDiff,
|
530
537
|
year = this.year() - inputMoment.year(),
|
531
538
|
month = this.month() - inputMoment.month(),
|
532
|
-
|
539
|
+
date = this.date() - inputMoment.date(),
|
533
540
|
output;
|
534
541
|
if (val === 'months') {
|
535
|
-
output = year * 12 + month +
|
542
|
+
output = year * 12 + month + date / 30;
|
536
543
|
} else if (val === 'years') {
|
537
544
|
output = year + month / 12;
|
538
545
|
} else {
|
@@ -541,7 +548,7 @@
|
|
541
548
|
val === 'hours' ? diff / 36e5 : // 1000 * 60 * 60
|
542
549
|
val === 'days' ? diff / 864e5 : // 1000 * 60 * 60 * 24
|
543
550
|
val === 'weeks' ? diff / 6048e5 : // 1000 * 60 * 60 * 24 * 7
|
544
|
-
|
551
|
+
diff;
|
545
552
|
}
|
546
553
|
return asFloat ? output : round(output);
|
547
554
|
},
|
@@ -558,9 +565,7 @@
|
|
558
565
|
},
|
559
566
|
|
560
567
|
calendar : function () {
|
561
|
-
var
|
562
|
-
todayAtZeroHour = moment([today.year(), today.month(), today.date()]),
|
563
|
-
diff = this.diff(todayAtZeroHour, 'days', true),
|
568
|
+
var diff = this.diff(moment().sod(), 'days', true),
|
564
569
|
calendar = moment.calendar,
|
565
570
|
allElse = calendar.sameElse,
|
566
571
|
format = diff < -6 ? allElse :
|
@@ -578,13 +583,30 @@
|
|
578
583
|
},
|
579
584
|
|
580
585
|
isDST : function () {
|
581
|
-
return this.zone()
|
586
|
+
return (this.zone() < moment([this.year()]).zone() ||
|
587
|
+
this.zone() < moment([this.year(), 5]).zone());
|
582
588
|
},
|
583
589
|
|
584
590
|
day : function (input) {
|
585
591
|
var day = this._d.getDay();
|
586
592
|
return input == null ? day :
|
587
593
|
this.add({ d : input - day });
|
594
|
+
},
|
595
|
+
|
596
|
+
sod: function () {
|
597
|
+
return this.clone()
|
598
|
+
.hours(0)
|
599
|
+
.minutes(0)
|
600
|
+
.seconds(0)
|
601
|
+
.milliseconds(0);
|
602
|
+
},
|
603
|
+
|
604
|
+
eod: function () {
|
605
|
+
// end of day = start of day plus 1 day, minus 1 millisecond
|
606
|
+
return this.sod().add({
|
607
|
+
d : 1,
|
608
|
+
ms : -1
|
609
|
+
});
|
588
610
|
}
|
589
611
|
};
|
590
612
|
|
@@ -620,5 +642,9 @@
|
|
620
642
|
if (typeof window !== 'undefined') {
|
621
643
|
window.moment = moment;
|
622
644
|
}
|
623
|
-
|
645
|
+
if (typeof define === "function" && define.amd) {
|
646
|
+
define("moment", [], function () {
|
647
|
+
return moment;
|
648
|
+
});
|
649
|
+
}
|
624
650
|
})(Date);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: momentjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &2160954780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2160954780
|
25
25
|
description: ! " Moment.js is a lightweight javascript date library for parsing,
|
26
26
|
manipulating, and formatting dates.\n This gem allows for its easy inclusion
|
27
27
|
into the rails asset pipeline.\n"
|
@@ -32,6 +32,7 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- lib/momentjs-rails.rb
|
34
34
|
- vendor/assets/javascripts/moment.js
|
35
|
+
- changelog.md
|
35
36
|
- MIT-LICENSE
|
36
37
|
- README.md
|
37
38
|
homepage: https://github.com/derekprior/momentjs-rails
|