momentjs-rails 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05d9abfe5085c85b3c1c25276455b53af15e746e
4
- data.tar.gz: 1b46ea4baeea50dfcc502b5a787ac80cd55f14c6
3
+ metadata.gz: 26eb8540bc610de37cf2c7e9e69de07878cc0af0
4
+ data.tar.gz: 7c4d2fa1f0f2ab5f324aaff5741a3ce4ce2543ae
5
5
  SHA512:
6
- metadata.gz: 64a99f42e2197d11b462e3cd6a2050d4123cf324f0430273fb4bb0fd212ed8ea3155b685485646e45ddcb523753e6416a87730e7ad382becc84a6300a1ac05fb
7
- data.tar.gz: defb86b1dce99f53e50a9d1a31eba9d42c6a7a7e5d1e7b5843b2ef4928373e6053bf7a5e4319ceb08e0999cdabac6357bc39a5203fa4d23a3172f05b13440990
6
+ metadata.gz: dab238e9515fdbdea5e8cdca93307e2412f3984368a83ecf85541ecaff8c7c080c19de90595ee7991ef711a3795d67564272c85fd6e38dde34ce87428bcce34f
7
+ data.tar.gz: efa50aa5bb9cf93b0573cc712cc9db6ea375ecd3f3aa3d8b04c6aaf90c9241b9a4a64aa1f5ef2a73bb2c97cc7489d217e144b5883dd7373106f0b252ce500823
data/README.md CHANGED
@@ -24,7 +24,7 @@ If you want to include a localization file, also add the following directive:
24
24
 
25
25
  ## Versioning
26
26
 
27
- momentjs-rails 2.4.0 == Moment.js 2.4.0
27
+ momentjs-rails 2.5.0 == Moment.js 2.5.0
28
28
 
29
29
  Every attempt is made to mirror the currently shipping Momentum.js version number wherever possible.
30
30
  The major, minor, and patch version numbers will always represent the Momentum.js version. Should a gem
data/news.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### Version 2.5.0 (2014-01-05)
2
+ - Updated to Moment.js to 2.5.0
3
+
1
4
  ### Version 2.4.0 (2013-11-13)
2
5
  - Updated to Moment.js to 2.4.0
3
6
 
@@ -1,153 +1,28 @@
1
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:04:06 -0400
2
- Compiled moment.js (0ms) (pid 43125)
3
- Served asset /moment.js - 200 OK (14ms)
4
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:04:06 -0400
5
- Compiled moment/fr.js (0ms) (pid 43125)
6
- Served asset /moment/fr.js - 200 OK (96ms)
7
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:05:04 -0400
8
- Served asset /moment.js - 200 OK (25ms)
9
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:05:04 -0400
10
- Served asset /moment/fr.js - 200 OK (2ms)
11
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:05:17 -0400
12
- Served asset /moment.js - 200 OK (2ms)
13
- Started GET "/assets/momentmotherfucker/fr.js" for 127.0.0.1 at 2013-03-16 16:05:17 -0400
14
- Served asset /momentmotherfucker/fr.js - 404 Not Found (1ms)
15
- Started GET "/assets/moments.js" for 127.0.0.1 at 2013-03-16 16:05:53 -0400
16
- Served asset /moments.js - 404 Not Found (1ms)
17
- Started GET "/assets/moment/rfr.js" for 127.0.0.1 at 2013-03-16 16:05:53 -0400
18
- Served asset /moment/rfr.js - 404 Not Found (1ms)
19
- Started GET "/assets/moments.js" for 127.0.0.1 at 2013-03-16 16:06:02 -0400
20
- Served asset /moments.js - 404 Not Found (1ms)
21
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:06:02 -0400
22
- Served asset /moment/fr.js - 200 OK (2ms)
23
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:06:22 -0400
24
- Served asset /moment.js - 200 OK (2ms)
25
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:06:22 -0400
26
- Served asset /moment/fr.js - 200 OK (1ms)
27
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:07:08 -0400
28
- Served asset /moment.js - 200 OK (3ms)
29
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:07:08 -0400
30
- Served asset /moment/fr.js - 200 OK (1ms)
31
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:08:10 -0400
32
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:08:10 -0400
33
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:08:17 -0400
34
- Served asset /moment.js - 200 OK (2ms)
35
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:08:17 -0400
36
- Served asset /moment/fr.js - 200 OK (1ms)
37
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:08:51 -0400
38
- Served asset /moment.js - 200 OK (2ms)
39
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:08:51 -0400
40
- Served asset /moment/fr.js - 200 OK (1ms)
41
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:08:57 -0400
42
- Served asset /moment.js - 200 OK (2ms)
43
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:08:57 -0400
44
- Served asset /moment/fr.js - 200 OK (1ms)
45
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:09:13 -0400
46
- Served asset /moment.js - 200 OK (2ms)
47
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:09:13 -0400
48
- Served asset /moment/fr.js - 200 OK (2ms)
49
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:09:49 -0400
50
- Served asset /moment.js - 200 OK (2ms)
51
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:09:49 -0400
52
- Served asset /moment/fr.js - 200 OK (1ms)
53
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:10:05 -0400
54
- Served asset /moment.js - 200 OK (2ms)
55
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:10:05 -0400
56
- Served asset /moment/fr.js - 200 OK (1ms)
57
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:11:18 -0400
58
- Served asset /moment.js - 200 OK (2ms)
59
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:11:18 -0400
60
- Served asset /moment/fr.js - 200 OK (1ms)
61
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:12:28 -0400
62
- Served asset /moment.js - 200 OK (16ms)
63
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:12:28 -0400
64
- Served asset /moment/fr.js - 200 OK (10ms)
65
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:12:47 -0400
66
- Served asset /moment.js - 200 OK (1ms)
67
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:12:47 -0400
68
- Served asset /moment/fr.js - 200 OK (11ms)
69
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:14:04 -0400
70
- Served asset /moment.js - 200 OK (1ms)
71
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:14:04 -0400
72
- Served asset /moment/fr.js - 200 OK (1ms)
73
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:15:39 -0400
74
- Served asset /moment.js - 200 OK (1ms)
75
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:15:39 -0400
76
- Served asset /moment/fr.js - 200 OK (12ms)
77
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:37:24 -0400
78
- Served asset /moment.js - 200 OK (14ms)
79
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:37:24 -0400
80
- Served asset /moment/fr.js - 200 OK (11ms)
81
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:37:32 -0400
82
- Served asset /moment.js - 200 OK (1ms)
83
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:37:32 -0400
84
- Served asset /moment/fr.js - 200 OK (12ms)
85
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:44:51 -0400
86
- Served asset /moment.js - 200 OK (46ms)
87
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:44:52 -0400
88
- Served asset /moment/fr.js - 200 OK (12ms)
89
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:44:52 -0400
1
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:00:54 -0400
2
+ Compiled moment.js (0ms) (pid 11385)
3
+ Served asset /moment.js - 200 OK (6ms)
4
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-09-19 11:00:54 -0400
5
+ Compiled moment/fr.js (0ms) (pid 11385)
6
+ Served asset /moment/fr.js - 200 OK (23ms)
7
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:00:54 -0400
90
8
  Served asset /moment.js - 200 OK (0ms)
91
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:45:09 -0400
92
- Served asset /moment.js - 200 OK (1ms)
93
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:45:09 -0400
94
- Served asset /moment/fr.js - 200 OK (11ms)
95
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:45:09 -0400
96
- Served asset /moment.js - 200 OK (0ms)
97
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:47:53 -0400
98
- Compiled moment.js (0ms) (pid 62815)
99
- Served asset /moment.js - 200 OK (18ms)
100
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:47:53 -0400
101
- Compiled moment/fr.js (0ms) (pid 62815)
102
- Served asset /moment/fr.js - 200 OK (18ms)
103
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:47:53 -0400
104
- Served asset /moment.js - 200 OK (0ms)
105
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:48:16 -0400
106
- Served asset /moment.js - 200 OK (2ms)
107
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:48:16 -0400
9
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:01:37 -0400
10
+ Served asset /moment.js - 200 OK (11ms)
11
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-09-19 11:01:37 -0400
108
12
  Served asset /moment/fr.js - 200 OK (1ms)
109
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:48:16 -0400
110
- Served asset /moment.js - 200 OK (0ms)
111
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:50:40 -0400
112
- Compiled moment.js (10ms) (pid 64044)
113
- Served asset /moment.js - 200 OK (40ms)
114
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:50:40 -0400
115
- Served asset /moment/fr.js - 200 OK (2ms)
116
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:50:40 -0400
117
- Served asset /moment.js - 200 OK (0ms)
118
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:50:53 -0400
119
- Compiled moment.js (11ms) (pid 64218)
120
- Served asset /moment.js - 200 OK (16ms)
121
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-03-16 16:50:53 -0400
122
- Served asset /moment/fr.js - 200 OK (1ms)
123
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-03-16 16:50:53 -0400
124
- Served asset /moment.js - 200 OK (0ms)
125
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-06-06 21:49:55 -0400
126
- Served asset /moment.js - 200 OK (2ms)
127
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-06-06 21:49:55 -0400
128
- Compiled moment/fr.js (0ms) (pid 73048)
129
- Served asset /moment/fr.js - 200 OK (28ms)
130
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-06-06 21:49:55 -0400
131
- Served asset /moment.js - 200 OK (0ms)
132
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-07-20 10:00:25 -0400
133
- Compiled moment.js (0ms) (pid 5373)
134
- Served asset /moment.js - 200 OK (75ms)
135
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-07-20 10:00:25 -0400
136
- Compiled moment/fr.js (0ms) (pid 5373)
137
- Served asset /moment/fr.js - 200 OK (96ms)
138
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-07-20 10:00:25 -0400
13
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:01:37 -0400
139
14
  Served asset /moment.js - 200 OK (0ms)
140
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-07-20 10:01:19 -0400
15
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:02:11 -0400
141
16
  Served asset /moment.js - 200 OK (2ms)
142
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-07-20 10:01:19 -0400
17
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-09-19 11:02:11 -0400
143
18
  Served asset /moment/fr.js - 200 OK (1ms)
144
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-07-20 10:01:19 -0400
19
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:02:11 -0400
145
20
  Served asset /moment.js - 200 OK (0ms)
146
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-11-14 20:25:32 -0500
147
- Compiled moment.js (1ms) (pid 43502)
148
- Served asset /moment.js - 200 OK (78ms)
149
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-11-14 20:25:32 -0500
150
- Compiled moment/fr.js (0ms) (pid 43502)
151
- Served asset /moment/fr.js - 200 OK (28ms)
152
- Started GET "/assets/moment.js" for 127.0.0.1 at 2013-11-14 20:25:32 -0500
21
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-09 09:25:18 -0500
22
+ Compiled moment.js (1ms) (pid 4859)
23
+ Served asset /moment.js - 200 OK (10ms)
24
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2014-01-09 09:25:18 -0500
25
+ Compiled moment/fr.js (0ms) (pid 4859)
26
+ Served asset /moment/fr.js - 200 OK (4ms)
27
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-09 09:25:18 -0500
153
28
  Served asset /moment.js - 200 OK (0ms)
@@ -8,7 +8,7 @@ class NavigationTest < ActionDispatch::IntegrationTest
8
8
 
9
9
  test 'momentjs response is for the expected version' do
10
10
  get 'assets/moment.js'
11
- assert_match(/VERSION = "2\.4\.0"/, @response.body)
11
+ assert_match(/VERSION = "2\.5\.0"/, @response.body)
12
12
  end
13
13
 
14
14
  test 'can access momentjs translation' do
@@ -1,5 +1,5 @@
1
1
  //! moment.js
2
- //! version : 2.4.0
2
+ //! version : 2.5.0
3
3
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
4
4
  //! license : MIT
5
5
  //! momentjs.com
@@ -11,7 +11,8 @@
11
11
  ************************************/
12
12
 
13
13
  var moment,
14
- VERSION = "2.4.0",
14
+ VERSION = "2.5.0",
15
+ global = this,
15
16
  round = Math.round,
16
17
  i,
17
18
 
@@ -27,7 +28,7 @@
27
28
  languages = {},
28
29
 
29
30
  // check for nodeJS
30
- hasModule = (typeof module !== 'undefined' && module.exports),
31
+ hasModule = (typeof module !== 'undefined' && module.exports && typeof require !== 'undefined'),
31
32
 
32
33
  // ASP.NET json date format regex
33
34
  aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
@@ -38,24 +39,30 @@
38
39
  isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
39
40
 
40
41
  // format tokens
41
- formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
42
+ formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
42
43
  localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
43
44
 
44
45
  // parsing token regexes
45
46
  parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
46
47
  parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999
47
- parseTokenThreeDigits = /\d{3}/, // 000 - 999
48
- parseTokenFourDigits = /\d{1,4}/, // 0 - 9999
49
- parseTokenSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999
48
+ parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999
49
+ parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999
50
50
  parseTokenDigits = /\d+/, // nonzero number of digits
51
51
  parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.
52
- parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, // +00:00 -00:00 +0000 -0000 or Z
53
- parseTokenT = /T/i, // T (ISO seperator)
52
+ parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
53
+ parseTokenT = /T/i, // T (ISO separator)
54
54
  parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
55
55
 
56
- // preliminary iso regex
57
- // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000)
58
- isoRegex = /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d:?\d\d|Z)?)?$/,
56
+ //strict parsing regexes
57
+ parseTokenOneDigit = /\d/, // 0 - 9
58
+ parseTokenTwoDigits = /\d\d/, // 00 - 99
59
+ parseTokenThreeDigits = /\d{3}/, // 000 - 999
60
+ parseTokenFourDigits = /\d{4}/, // 0000 - 9999
61
+ parseTokenSixDigits = /[+\-]?\d{6}/, // -999,999 - 999,999
62
+
63
+ // iso 8601 regex
64
+ // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
65
+ isoRegex = /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
59
66
 
60
67
  isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
61
68
 
@@ -165,6 +172,10 @@
165
172
  YYYYY : function () {
166
173
  return leftZeroFill(this.year(), 5);
167
174
  },
175
+ YYYYYY : function () {
176
+ var y = this.year(), sign = y >= 0 ? '+' : '-';
177
+ return sign + leftZeroFill(Math.abs(y), 6);
178
+ },
168
179
  gg : function () {
169
180
  return leftZeroFill(this.weekYear() % 100, 2);
170
181
  },
@@ -235,7 +246,7 @@
235
246
  a = -a;
236
247
  b = "-";
237
248
  }
238
- return b + leftZeroFill(toInt(10 * a / 6), 4);
249
+ return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2);
239
250
  },
240
251
  z : function () {
241
252
  return this.zoneAbbr();
@@ -245,6 +256,9 @@
245
256
  },
246
257
  X : function () {
247
258
  return this.unix();
259
+ },
260
+ Q : function () {
261
+ return this.quarter();
248
262
  }
249
263
  },
250
264
 
@@ -298,9 +312,6 @@
298
312
  seconds = normalizedInput.second || 0,
299
313
  milliseconds = normalizedInput.millisecond || 0;
300
314
 
301
- // store reference to input for deterministic cloning
302
- this._input = duration;
303
-
304
315
  // representation for dateAddRemove
305
316
  this._milliseconds = +milliseconds +
306
317
  seconds * 1e3 + // 1000
@@ -354,12 +365,14 @@
354
365
 
355
366
  // left zero fill a number
356
367
  // see http://jsperf.com/left-zero-filling for performance comparison
357
- function leftZeroFill(number, targetLength) {
358
- var output = number + '';
368
+ function leftZeroFill(number, targetLength, forceSign) {
369
+ var output = Math.abs(number) + '',
370
+ sign = number >= 0;
371
+
359
372
  while (output.length < targetLength) {
360
373
  output = '0' + output;
361
374
  }
362
- return output;
375
+ return (sign ? (forceSign ? '+' : '') : '-') + output;
363
376
  }
364
377
 
365
378
  // helper function for _.addTime and _.subtractTime
@@ -430,8 +443,7 @@
430
443
  function normalizeObjectUnits(inputObject) {
431
444
  var normalizedInput = {},
432
445
  normalizedProp,
433
- prop,
434
- index;
446
+ prop;
435
447
 
436
448
  for (prop in inputObject) {
437
449
  if (inputObject.hasOwnProperty(prop)) {
@@ -572,6 +584,12 @@
572
584
  return key ? key.toLowerCase().replace('_', '-') : key;
573
585
  }
574
586
 
587
+ // Return a moment from input, that is local/utc/zone equivalent to model.
588
+ function makeAs(input, model) {
589
+ return model._isUTC ? moment(input).zone(model._offset || 0) :
590
+ moment(input).local();
591
+ }
592
+
575
593
  /************************************
576
594
  Languages
577
595
  ************************************/
@@ -903,23 +921,28 @@
903
921
 
904
922
  // get the regex to find the next token
905
923
  function getParseRegexForToken(token, config) {
906
- var a;
924
+ var a, strict = config._strict;
907
925
  switch (token) {
908
926
  case 'DDDD':
909
927
  return parseTokenThreeDigits;
910
928
  case 'YYYY':
911
929
  case 'GGGG':
912
930
  case 'gggg':
913
- return parseTokenFourDigits;
931
+ return strict ? parseTokenFourDigits : parseTokenOneToFourDigits;
932
+ case 'YYYYYY':
914
933
  case 'YYYYY':
915
934
  case 'GGGGG':
916
935
  case 'ggggg':
917
- return parseTokenSixDigits;
936
+ return strict ? parseTokenSixDigits : parseTokenOneToSixDigits;
918
937
  case 'S':
938
+ if (strict) { return parseTokenOneDigit; }
939
+ /* falls through */
919
940
  case 'SS':
941
+ if (strict) { return parseTokenTwoDigits; }
942
+ /* falls through */
920
943
  case 'SSS':
921
944
  case 'DDD':
922
- return parseTokenOneToThreeDigits;
945
+ return strict ? parseTokenThreeDigits : parseTokenOneToThreeDigits;
923
946
  case 'MMM':
924
947
  case 'MMMM':
925
948
  case 'dd':
@@ -947,6 +970,9 @@
947
970
  case 'hh':
948
971
  case 'mm':
949
972
  case 'ss':
973
+ case 'ww':
974
+ case 'WW':
975
+ return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits;
950
976
  case 'M':
951
977
  case 'D':
952
978
  case 'd':
@@ -955,12 +981,10 @@
955
981
  case 'm':
956
982
  case 's':
957
983
  case 'w':
958
- case 'ww':
959
984
  case 'W':
960
- case 'WW':
961
985
  case 'e':
962
986
  case 'E':
963
- return parseTokenOneOrTwoDigits;
987
+ return strict ? parseTokenOneDigit : parseTokenOneOrTwoDigits;
964
988
  default :
965
989
  a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i"));
966
990
  return a;
@@ -968,8 +992,10 @@
968
992
  }
969
993
 
970
994
  function timezoneMinutesFromString(string) {
971
- var tzchunk = (parseTokenTimezone.exec(string) || [])[0],
972
- parts = (tzchunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
995
+ string = string || "";
996
+ var possibleTzMatches = (string.match(parseTokenTimezone) || []),
997
+ tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
998
+ parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
973
999
  minutes = +(parts[1] * 60) + toInt(parts[2]);
974
1000
 
975
1001
  return parts[0] === '+' ? -minutes : minutes;
@@ -1018,6 +1044,7 @@
1018
1044
  break;
1019
1045
  case 'YYYY' :
1020
1046
  case 'YYYYY' :
1047
+ case 'YYYYYY' :
1021
1048
  datePartArray[YEAR] = toInt(input);
1022
1049
  break;
1023
1050
  // AM / PM
@@ -1102,8 +1129,9 @@
1102
1129
  //compute day of the year from weeks and weekdays
1103
1130
  if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
1104
1131
  fixYear = function (val) {
1132
+ var int_val = parseInt(val, 10);
1105
1133
  return val ?
1106
- (val.length < 3 ? (parseInt(val, 10) > 68 ? '19' + val : '20' + val) : val) :
1134
+ (val.length < 3 ? (int_val > 68 ? 1900 + int_val : 2000 + int_val) : int_val) :
1107
1135
  (config._a[YEAR] == null ? moment().weekYear() : config._a[YEAR]);
1108
1136
  };
1109
1137
 
@@ -1215,7 +1243,7 @@
1215
1243
 
1216
1244
  for (i = 0; i < tokens.length; i++) {
1217
1245
  token = tokens[i];
1218
- parsedInput = (getParseRegexForToken(token, config).exec(string) || [])[0];
1246
+ parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
1219
1247
  if (parsedInput) {
1220
1248
  skipped = string.substr(0, string.indexOf(parsedInput));
1221
1249
  if (skipped.length > 0) {
@@ -1333,7 +1361,7 @@
1333
1361
  break;
1334
1362
  }
1335
1363
  }
1336
- if (parseTokenTimezone.exec(string)) {
1364
+ if (string.match(parseTokenTimezone)) {
1337
1365
  config._f += "Z";
1338
1366
  }
1339
1367
  makeDateFromStringAndFormat(config);
@@ -1468,7 +1496,10 @@
1468
1496
 
1469
1497
  //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1470
1498
  function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
1471
- var d = new Date(Date.UTC(year, 0)).getUTCDay(),
1499
+ // The only solid way to create an iso date from year is to use
1500
+ // a string format (Date.UTC handles only years > 1900). Don't ask why
1501
+ // it doesn't need Z at the end.
1502
+ var d = new Date(leftZeroFill(year, 6, true) + '-01-01').getUTCDay(),
1472
1503
  daysToAdd, dayOfYear;
1473
1504
 
1474
1505
  weekday = weekday != null ? weekday : firstDayOfWeek;
@@ -1559,18 +1590,21 @@
1559
1590
 
1560
1591
  // duration
1561
1592
  moment.duration = function (input, key) {
1562
- var isDuration = moment.isDuration(input),
1563
- isNumber = (typeof input === 'number'),
1564
- duration = (isDuration ? input._input : (isNumber ? {} : input)),
1593
+ var duration = input,
1565
1594
  // matching against regexp is expensive, do it on demand
1566
1595
  match = null,
1567
1596
  sign,
1568
1597
  ret,
1569
- parseIso,
1570
- timeEmpty,
1571
- dateTimeEmpty;
1598
+ parseIso;
1572
1599
 
1573
- if (isNumber) {
1600
+ if (moment.isDuration(input)) {
1601
+ duration = {
1602
+ ms: input._milliseconds,
1603
+ d: input._days,
1604
+ M: input._months
1605
+ };
1606
+ } else if (typeof input === 'number') {
1607
+ duration = {};
1574
1608
  if (key) {
1575
1609
  duration[key] = input;
1576
1610
  } else {
@@ -1609,7 +1643,7 @@
1609
1643
 
1610
1644
  ret = new Duration(duration);
1611
1645
 
1612
- if (isDuration && input.hasOwnProperty('_lang')) {
1646
+ if (moment.isDuration(input) && input.hasOwnProperty('_lang')) {
1613
1647
  ret._lang = input._lang;
1614
1648
  }
1615
1649
 
@@ -1716,7 +1750,12 @@
1716
1750
  },
1717
1751
 
1718
1752
  toISOString : function () {
1719
- return formatMoment(moment(this).utc(), 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1753
+ var m = moment(this).utc();
1754
+ if (0 < m.year() && m.year() <= 9999) {
1755
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1756
+ } else {
1757
+ return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1758
+ }
1720
1759
  },
1721
1760
 
1722
1761
  toArray : function () {
@@ -1793,7 +1832,7 @@
1793
1832
  },
1794
1833
 
1795
1834
  diff : function (input, units, asFloat) {
1796
- var that = this._isUTC ? moment(input).zone(this._offset || 0) : moment(input).local(),
1835
+ var that = makeAs(input, this),
1797
1836
  zoneDiff = (this.zone() - that.zone()) * 6e4,
1798
1837
  diff, output;
1799
1838
 
@@ -1835,13 +1874,16 @@
1835
1874
  },
1836
1875
 
1837
1876
  calendar : function () {
1838
- var diff = this.diff(moment().zone(this.zone()).startOf('day'), 'days', true),
1877
+ // We want to compare the start of today, vs this.
1878
+ // Getting start-of-today depends on whether we're zone'd or not.
1879
+ var sod = makeAs(moment(), this).startOf('day'),
1880
+ diff = this.diff(sod, 'days', true),
1839
1881
  format = diff < -6 ? 'sameElse' :
1840
- diff < -1 ? 'lastWeek' :
1841
- diff < 0 ? 'lastDay' :
1842
- diff < 1 ? 'sameDay' :
1843
- diff < 2 ? 'nextDay' :
1844
- diff < 7 ? 'nextWeek' : 'sameElse';
1882
+ diff < -1 ? 'lastWeek' :
1883
+ diff < 0 ? 'lastDay' :
1884
+ diff < 1 ? 'sameDay' :
1885
+ diff < 2 ? 'nextDay' :
1886
+ diff < 7 ? 'nextWeek' : 'sameElse';
1845
1887
  return this.format(this.lang().calendar(format, this));
1846
1888
  },
1847
1889
 
@@ -1941,8 +1983,8 @@
1941
1983
  },
1942
1984
 
1943
1985
  isSame: function (input, units) {
1944
- units = typeof units !== 'undefined' ? units : 'millisecond';
1945
- return +this.clone().startOf(units) === +moment(input).startOf(units);
1986
+ units = units || 'ms';
1987
+ return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
1946
1988
  },
1947
1989
 
1948
1990
  min: function (other) {
@@ -1984,7 +2026,9 @@
1984
2026
  },
1985
2027
 
1986
2028
  parseZone : function () {
1987
- if (typeof this._i === 'string') {
2029
+ if (this._tzm) {
2030
+ this.zone(this._tzm);
2031
+ } else if (typeof this._i === 'string') {
1988
2032
  this.zone(this._i);
1989
2033
  }
1990
2034
  return this;
@@ -2010,6 +2054,10 @@
2010
2054
  return input == null ? dayOfYear : this.add("d", (input - dayOfYear));
2011
2055
  },
2012
2056
 
2057
+ quarter : function () {
2058
+ return Math.ceil((this.month() + 1.0) / 3.0);
2059
+ },
2060
+
2013
2061
  weekYear : function (input) {
2014
2062
  var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year;
2015
2063
  return input == null ? year : this.add("y", (input - year));
@@ -2280,7 +2328,7 @@
2280
2328
  // add `moment` as a global object via a string identifier,
2281
2329
  // for Closure Compiler "advanced" mode
2282
2330
  if (deprecate) {
2283
- this.moment = function () {
2331
+ global.moment = function () {
2284
2332
  if (!warned && console && console.warn) {
2285
2333
  warned = true;
2286
2334
  console.warn(
@@ -2290,8 +2338,9 @@
2290
2338
  }
2291
2339
  return local_moment.apply(null, arguments);
2292
2340
  };
2341
+ extend(global.moment, local_moment);
2293
2342
  } else {
2294
- this['moment'] = moment;
2343
+ global['moment'] = moment;
2295
2344
  }
2296
2345
  }
2297
2346
 
@@ -2301,7 +2350,7 @@
2301
2350
  makeGlobal(true);
2302
2351
  } else if (typeof define === "function" && define.amd) {
2303
2352
  define("moment", function (require, exports, module) {
2304
- if (module.config().noGlobal !== true) {
2353
+ if (module.config && module.config() && module.config().noGlobal !== true) {
2305
2354
  // If user provided noGlobal, he is aware of global
2306
2355
  makeGlobal(module.config().noGlobal === undefined);
2307
2356
  }