momentjs-rails 2.8.3 → 2.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/news.md +14 -11
  4. data/test/dummy/log/test.log +45 -12
  5. data/test/dummy/tmp/cache/assets/D1C/680/sprockets%2F16ed4d5afdb2919596e6f8790e2116c2 +0 -0
  6. data/test/dummy/tmp/cache/assets/D35/CA0/sprockets%2F493e64bce2d302801dc01cf7cd096a58 +0 -0
  7. data/test/dummy/tmp/cache/assets/{DF2/E30/sprockets%2F655dba52b71aafead92214b8d4f15dfb → D3F/5F0/sprockets%2F4a6c53eae7c6e41a69a191578bbb6417} +0 -0
  8. data/test/dummy/tmp/cache/assets/{D46/140/sprockets%2F547811dd40877ace277331ae79ec4efa → D58/BD0/sprockets%2F4de9ddc9b725c715a54c98697b2528fe} +0 -0
  9. data/test/dummy/tmp/cache/assets/{D70/7B0/sprockets%2F28ee037740c82f4b2d895db4fb4a27cc → D75/510/sprockets%2Fe690787ac522f47a6be024bfcc1767ee} +0 -0
  10. data/test/dummy/tmp/cache/assets/E10/250/sprockets%2Fe4badb9ddfda484eb9671bf88567be61 +0 -0
  11. data/test/integration/navigation_test.rb +3 -3
  12. data/vendor/assets/javascripts/moment.js +114 -34
  13. data/vendor/assets/javascripts/moment/af.js +3 -1
  14. data/vendor/assets/javascripts/moment/ar-ma.js +2 -1
  15. data/vendor/assets/javascripts/moment/ar-sa.js +3 -2
  16. data/vendor/assets/javascripts/moment/ar.js +3 -2
  17. data/vendor/assets/javascripts/moment/az.js +3 -1
  18. data/vendor/assets/javascripts/moment/be.js +3 -1
  19. data/vendor/assets/javascripts/moment/bg.js +3 -1
  20. data/vendor/assets/javascripts/moment/bn.js +2 -1
  21. data/vendor/assets/javascripts/moment/bo.js +2 -1
  22. data/vendor/assets/javascripts/moment/br.js +3 -1
  23. data/vendor/assets/javascripts/moment/bs.js +5 -3
  24. data/vendor/assets/javascripts/moment/ca.js +13 -2
  25. data/vendor/assets/javascripts/moment/cs.js +4 -2
  26. data/vendor/assets/javascripts/moment/cv.js +3 -1
  27. data/vendor/assets/javascripts/moment/cy.js +3 -1
  28. data/vendor/assets/javascripts/moment/da.js +3 -1
  29. data/vendor/assets/javascripts/moment/de-at.js +9 -7
  30. data/vendor/assets/javascripts/moment/de.js +9 -7
  31. data/vendor/assets/javascripts/moment/el.js +5 -5
  32. data/vendor/assets/javascripts/moment/en-au.js +3 -1
  33. data/vendor/assets/javascripts/moment/en-ca.js +3 -1
  34. data/vendor/assets/javascripts/moment/en-gb.js +3 -1
  35. data/vendor/assets/javascripts/moment/eo.js +3 -1
  36. data/vendor/assets/javascripts/moment/es.js +3 -1
  37. data/vendor/assets/javascripts/moment/et.js +3 -1
  38. data/vendor/assets/javascripts/moment/eu.js +3 -1
  39. data/vendor/assets/javascripts/moment/fa.js +3 -1
  40. data/vendor/assets/javascripts/moment/fi.js +3 -1
  41. data/vendor/assets/javascripts/moment/fo.js +3 -1
  42. data/vendor/assets/javascripts/moment/fr-ca.js +3 -1
  43. data/vendor/assets/javascripts/moment/fr.js +3 -1
  44. data/vendor/assets/javascripts/moment/gl.js +3 -1
  45. data/vendor/assets/javascripts/moment/he.js +2 -1
  46. data/vendor/assets/javascripts/moment/hi.js +2 -1
  47. data/vendor/assets/javascripts/moment/hr.js +3 -1
  48. data/vendor/assets/javascripts/moment/hu.js +3 -1
  49. data/vendor/assets/javascripts/moment/hy-am.js +3 -1
  50. data/vendor/assets/javascripts/moment/id.js +2 -1
  51. data/vendor/assets/javascripts/moment/is.js +3 -1
  52. data/vendor/assets/javascripts/moment/it.js +11 -2
  53. data/vendor/assets/javascripts/moment/ja.js +2 -1
  54. data/vendor/assets/javascripts/moment/ka.js +3 -1
  55. data/vendor/assets/javascripts/moment/km.js +2 -1
  56. data/vendor/assets/javascripts/moment/ko.js +3 -1
  57. data/vendor/assets/javascripts/moment/lb.js +3 -1
  58. data/vendor/assets/javascripts/moment/lt.js +3 -1
  59. data/vendor/assets/javascripts/moment/lv.js +3 -1
  60. data/vendor/assets/javascripts/moment/mk.js +3 -1
  61. data/vendor/assets/javascripts/moment/ml.js +2 -1
  62. data/vendor/assets/javascripts/moment/mr.js +2 -1
  63. data/vendor/assets/javascripts/moment/ms-my.js +2 -1
  64. data/vendor/assets/javascripts/moment/my.js +2 -1
  65. data/vendor/assets/javascripts/moment/nb.js +3 -1
  66. data/vendor/assets/javascripts/moment/ne.js +2 -1
  67. data/vendor/assets/javascripts/moment/nl.js +3 -1
  68. data/vendor/assets/javascripts/moment/nn.js +3 -1
  69. data/vendor/assets/javascripts/moment/pl.js +3 -1
  70. data/vendor/assets/javascripts/moment/pt-br.js +3 -1
  71. data/vendor/assets/javascripts/moment/pt.js +3 -1
  72. data/vendor/assets/javascripts/moment/ro.js +2 -1
  73. data/vendor/assets/javascripts/moment/ru.js +25 -15
  74. data/vendor/assets/javascripts/moment/sk.js +3 -1
  75. data/vendor/assets/javascripts/moment/sl.js +3 -1
  76. data/vendor/assets/javascripts/moment/sq.js +3 -1
  77. data/vendor/assets/javascripts/moment/sr-cyrl.js +3 -1
  78. data/vendor/assets/javascripts/moment/sr.js +3 -1
  79. data/vendor/assets/javascripts/moment/sv.js +3 -1
  80. data/vendor/assets/javascripts/moment/ta.js +3 -1
  81. data/vendor/assets/javascripts/moment/th.js +2 -1
  82. data/vendor/assets/javascripts/moment/tl-ph.js +3 -1
  83. data/vendor/assets/javascripts/moment/tr.js +3 -1
  84. data/vendor/assets/javascripts/moment/tzm-latn.js +2 -1
  85. data/vendor/assets/javascripts/moment/tzm.js +2 -1
  86. data/vendor/assets/javascripts/moment/uk.js +3 -1
  87. data/vendor/assets/javascripts/moment/uz.js +2 -1
  88. data/vendor/assets/javascripts/moment/vi.js +3 -1
  89. data/vendor/assets/javascripts/moment/zh-cn.js +3 -1
  90. data/vendor/assets/javascripts/moment/zh-tw.js +3 -1
  91. metadata +15 -19
  92. data/test/dummy/tmp/cache/assets/C4B/F20/sprockets%2F2a0b419661537b349a21d41ba3988990 +0 -0
  93. data/test/dummy/tmp/cache/assets/D4E/220/sprockets%2F8f4a628d82d9413ed7c75e8b373c9ab2 +0 -0
  94. data/test/dummy/tmp/cache/assets/E2B/3C0/sprockets%2Fd3a4fe71f7e32ca82bfabb6d7ef41f34 +0 -0
  95. data/vendor/assets/javascripts/moment/rs.js +0 -139
  96. data/vendor/assets/javascripts/moment/sr-cyr.js +0 -106
  97. data/vendor/assets/javascripts/moment/tzm-la.js +0 -55
  98. data/vendor/assets/javascripts/moment/vn.js +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ead75ba3769a872adc3b513d4357c43406cd2215
4
- data.tar.gz: ccf7ff4f26ff1537e102819d44d8bc8c0de3408a
3
+ metadata.gz: 23c8a02c47169e55915f6947a1a9dd59a9a0e538
4
+ data.tar.gz: 78bf924334052c3d41695969560e7dfd821a186c
5
5
  SHA512:
6
- metadata.gz: cbdc519b366c35ae481c1cbae30e95db9591e80c09f7bbb8e162eb7956b8fee11708faf4b490defc01cb400dbd04574295a042adb057e5f08aa4e172fcf2408a
7
- data.tar.gz: 54ca514cd991d5440902e5cc47e9621cedabb1c9baf17ef8ad3989e73edf227879c9bf06df81d7287b4d37d02e00488193f9286ae60c2f78a01e0b1f02a344f8
6
+ metadata.gz: 73e566feb723c94b83c96b05321e06414a10d7c631b558934de9c56400657bf916794ddc11c26f6f203bd11b253f1ee5f8074b0b07149ebd249d37dfce5d5aaa
7
+ data.tar.gz: dc5b695098eead50a23a7bed1ea25cc0071f37073f1e8fb7fe98ab927c4f208e2bada5d88246b4e8873e78ea87a265d0021754d37f27a980a07253b1497aa3f3
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # momentjs-rails
2
2
 
3
3
  momentjs-rails wraps the [Moment.js](http://momentjs.com/) library in a rails engine for simple
4
- use with the asset pipeline provided by rails 3.1. The gem includes the development (non-minified)
4
+ use with the asset pipeline provided by Rails 3.1 and higher. The gem includes the development (non-minified)
5
5
  source for ease of exploration. The asset pipeline will minify in production.
6
6
 
7
7
  Moment.js is "a lightweight javascript date library for parsing, manipulating, and formatting dates."
8
- Moment.js does not modify the native Date object. Rather, it creates a warpper for it. Please see the
8
+ Moment.js does not modify the native Date object. Rather, it creates a wrapper for it. Please see the
9
9
  [documentation](http://momentjs.com/docs/) for details.
10
10
 
11
11
  ## Usage
@@ -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.8.3 == Moment.js 2.8.3
27
+ momentjs-rails 2.8.4 == Moment.js 2.8.4
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,35 +1,38 @@
1
+ ### Version 2.8.4 (2015-01-12)
2
+ - Updated Moment.js 2.8.4
3
+
1
4
  ### Version 2.8.3 (2014-09-11)
2
- - Updated to Moment.js to 2.8.3
5
+ - Updated Moment.js to 2.8.3
3
6
 
4
7
  ### Version 2.8.2 (2014-09-11)
5
- - Updated to Moment.js to 2.8.2
8
+ - Updated Moment.js to 2.8.2
6
9
 
7
10
  ### Version 2.8.1 (2014-08-06)
8
- - Updated to Moment.js to 2.8.1
11
+ - Updated Moment.js to 2.8.1
9
12
 
10
13
  ### Version 2.8.0 (2014-08-06)
11
- - Updated to Moment.js to 2.8.0
14
+ - Updated Moment.js to 2.8.0
12
15
 
13
16
  ### Version 2.7.0 (2014-06-13)
14
- - Updated to Moment.js to 2.7.0
17
+ - Updated Moment.js to 2.7.0
15
18
 
16
19
  ### Version 2.6.0 (2014-04-25)
17
- - Updated to Moment.js to 2.6.0
20
+ - Updated Moment.js to 2.6.0
18
21
 
19
22
  ### Version 2.5.1 (2014-01-28)
20
- - Updated to Moment.js to 2.5.1
23
+ - Updated Moment.js to 2.5.1
21
24
 
22
25
  ### Version 2.5.0 (2014-01-05)
23
- - Updated to Moment.js to 2.5.0
26
+ - Updated Moment.js to 2.5.0
24
27
 
25
28
  ### Version 2.4.0 (2013-11-13)
26
- - Updated to Moment.js to 2.4.0
29
+ - Updated Moment.js to 2.4.0
27
30
 
28
31
  ### Version 2.2.1 (2013-09-19)
29
- - Updated to Moment.js to 2.2.1
32
+ - Updated Moment.js to 2.2.1
30
33
 
31
34
  ### Version 2.1.0 (2013-07-20)
32
- - Updated to Moment.js to 2.1.0
35
+ - Updated Moment.js to 2.1.0
33
36
  - Updated localization files using compressed versions (ready for browser)
34
37
 
35
38
  ### Version 2.0.0.2 (2013-06-06)
@@ -1,15 +1,48 @@
1
- Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-05 09:28:54 +0100
2
- Compiled moment.js (1ms) (pid 56387)
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
3
  Served asset /moment.js - 200 OK (6ms)
4
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2014-01-05 09:28:54 +0100
5
- Compiled moment/fr.js (0ms) (pid 56387)
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
8
+ Served asset /moment.js - 200 OK (0ms)
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
12
+ Served asset /moment/fr.js - 200 OK (1ms)
13
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:01:37 -0400
14
+ Served asset /moment.js - 200 OK (0ms)
15
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:02:11 -0400
16
+ Served asset /moment.js - 200 OK (2ms)
17
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2013-09-19 11:02:11 -0400
18
+ Served asset /moment/fr.js - 200 OK (1ms)
19
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2013-09-19 11:02:11 -0400
20
+ Served asset /moment.js - 200 OK (0ms)
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)
6
26
  Served asset /moment/fr.js - 200 OK (4ms)
7
- Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-05 09:28:54 +0100
8
- Served asset /moment.js - 200 OK (0ms)
9
- Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-28 12:36:31 +0100
10
- Compiled moment.js (1ms) (pid 21871)
11
- Served asset /moment.js - 200 OK (21ms)
12
- Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2014-01-28 12:36:31 +0100
13
- Served asset /moment/fr.js - 200 OK (3ms)
14
- Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-28 12:36:31 +0100
27
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2014-01-09 09:25:18 -0500
28
+ Served asset /moment.js - 200 OK (0ms)
29
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2015-01-12 15:43:59 -0500
30
+ Compiled moment.js (1ms) (pid 19537)
31
+ Served asset /moment.js - 200 OK (7ms)
32
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2015-01-12 15:43:59 -0500
33
+ Compiled moment/fr.js (0ms) (pid 19537)
34
+ Served asset /moment/fr.js - 200 OK (4ms)
35
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2015-01-12 15:43:59 -0500
36
+ Served asset /moment.js - 200 OK (0ms)
37
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2015-01-12 15:44:23 -0500
38
+ Served asset /moment.js - 200 OK (3ms)
39
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2015-01-12 15:44:23 -0500
40
+ Served asset /moment/fr.js - 200 OK (1ms)
41
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2015-01-12 15:44:23 -0500
42
+ Served asset /moment.js - 200 OK (0ms)
43
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2015-01-12 15:44:26 -0500
44
+ Served asset /moment.js - 200 OK (2ms)
45
+ Started GET "/assets/moment/fr.js" for 127.0.0.1 at 2015-01-12 15:44:26 -0500
46
+ Served asset /moment/fr.js - 200 OK (1ms)
47
+ Started GET "/assets/moment.js" for 127.0.0.1 at 2015-01-12 15:44:26 -0500
15
48
  Served asset /moment.js - 200 OK (0ms)
@@ -7,12 +7,12 @@ class NavigationTest < ActionDispatch::IntegrationTest
7
7
  end
8
8
 
9
9
  test 'momentjs response is for the expected version' do
10
- get 'assets/moment.js'
11
- assert_match(/VERSION = "2\.8\.3"/, @response.body)
10
+ get '/assets/moment.js'
11
+ assert_match(/VERSION = '2\.8\.4'/, @response.body)
12
12
  end
13
13
 
14
14
  test 'can access momentjs translation' do
15
- get 'assets/moment/fr.js'
15
+ get '/assets/moment/fr.js'
16
16
  assert_response :success
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  //! moment.js
2
- //! version : 2.8.3
2
+ //! version : 2.8.4
3
3
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
4
4
  //! license : MIT
5
5
  //! momentjs.com
@@ -10,7 +10,7 @@
10
10
  ************************************/
11
11
 
12
12
  var moment,
13
- VERSION = '2.8.3',
13
+ VERSION = '2.8.4',
14
14
  // the global-scope this is NOT the global object in Node.js
15
15
  globalScope = typeof global !== 'undefined' ? global : this,
16
16
  oldGlobalMoment,
@@ -33,7 +33,7 @@
33
33
  momentProperties = [],
34
34
 
35
35
  // check for nodeJS
36
- hasModule = (typeof module !== 'undefined' && module.exports),
36
+ hasModule = (typeof module !== 'undefined' && module && module.exports),
37
37
 
38
38
  // ASP.NET json date format regex
39
39
  aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
@@ -44,8 +44,8 @@
44
44
  isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
45
45
 
46
46
  // format tokens
47
- formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
48
- localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
47
+ formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,
48
+ localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
49
49
 
50
50
  // parsing token regexes
51
51
  parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
@@ -56,8 +56,8 @@
56
56
  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.
57
57
  parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
58
58
  parseTokenT = /T/i, // T (ISO separator)
59
+ parseTokenOffsetMs = /[\+\-]?\d+/, // 1234567890123
59
60
  parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
60
- parseTokenOrdinal = /\d{1,2}/,
61
61
 
62
62
  //strict parsing regexes
63
63
  parseTokenOneDigit = /\d/, // 0 - 9
@@ -272,6 +272,9 @@
272
272
  zz : function () {
273
273
  return this.zoneName();
274
274
  },
275
+ x : function () {
276
+ return this.valueOf();
277
+ },
275
278
  X : function () {
276
279
  return this.unix();
277
280
  },
@@ -698,7 +701,10 @@
698
701
  overflow =
699
702
  m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :
700
703
  m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :
701
- m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR :
704
+ m._a[HOUR] < 0 || m._a[HOUR] > 24 ||
705
+ (m._a[HOUR] === 24 && (m._a[MINUTE] !== 0 ||
706
+ m._a[SECOND] !== 0 ||
707
+ m._a[MILLISECOND] !== 0)) ? HOUR :
702
708
  m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE :
703
709
  m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND :
704
710
  m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND :
@@ -725,7 +731,8 @@
725
731
  if (m._strict) {
726
732
  m._isValid = m._isValid &&
727
733
  m._pf.charsLeftOver === 0 &&
728
- m._pf.unusedTokens.length === 0;
734
+ m._pf.unusedTokens.length === 0 &&
735
+ m._pf.bigHour === undefined;
729
736
  }
730
737
  }
731
738
  return m._isValid;
@@ -777,8 +784,18 @@
777
784
 
778
785
  // Return a moment from input, that is local/utc/zone equivalent to model.
779
786
  function makeAs(input, model) {
780
- return model._isUTC ? moment(input).zone(model._offset || 0) :
781
- moment(input).local();
787
+ var res, diff;
788
+ if (model._isUTC) {
789
+ res = model.clone();
790
+ diff = (moment.isMoment(input) || isDate(input) ?
791
+ +input : +moment(input)) - (+res);
792
+ // Use low-level api, because this fn is low-level api.
793
+ res._d.setTime(+res._d + diff);
794
+ moment.updateOffset(res, false);
795
+ return res;
796
+ } else {
797
+ return moment(input).local();
798
+ }
782
799
  }
783
800
 
784
801
  /************************************
@@ -798,6 +815,9 @@
798
815
  this['_' + i] = prop;
799
816
  }
800
817
  }
818
+ // Lenient ordinal parsing accepts just a number in addition to
819
+ // number + (possibly) stuff coming from _ordinalParseLenient.
820
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + /\d{1,2}/.source);
801
821
  },
802
822
 
803
823
  _months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
@@ -810,22 +830,32 @@
810
830
  return this._monthsShort[m.month()];
811
831
  },
812
832
 
813
- monthsParse : function (monthName) {
833
+ monthsParse : function (monthName, format, strict) {
814
834
  var i, mom, regex;
815
835
 
816
836
  if (!this._monthsParse) {
817
837
  this._monthsParse = [];
838
+ this._longMonthsParse = [];
839
+ this._shortMonthsParse = [];
818
840
  }
819
841
 
820
842
  for (i = 0; i < 12; i++) {
821
843
  // make the regex if we don't have it already
822
- if (!this._monthsParse[i]) {
823
- mom = moment.utc([2000, i]);
844
+ mom = moment.utc([2000, i]);
845
+ if (strict && !this._longMonthsParse[i]) {
846
+ this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
847
+ this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
848
+ }
849
+ if (!strict && !this._monthsParse[i]) {
824
850
  regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
825
851
  this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
826
852
  }
827
853
  // test the regex
828
- if (this._monthsParse[i].test(monthName)) {
854
+ if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
855
+ return i;
856
+ } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
857
+ return i;
858
+ } else if (!strict && this._monthsParse[i].test(monthName)) {
829
859
  return i;
830
860
  }
831
861
  }
@@ -868,6 +898,7 @@
868
898
  },
869
899
 
870
900
  _longDateFormat : {
901
+ LTS : 'h:mm:ss A',
871
902
  LT : 'h:mm A',
872
903
  L : 'MM/DD/YYYY',
873
904
  LL : 'MMMM D, YYYY',
@@ -908,9 +939,9 @@
908
939
  lastWeek : '[Last] dddd [at] LT',
909
940
  sameElse : 'L'
910
941
  },
911
- calendar : function (key, mom) {
942
+ calendar : function (key, mom, now) {
912
943
  var output = this._calendar[key];
913
- return typeof output === 'function' ? output.apply(mom) : output;
944
+ return typeof output === 'function' ? output.apply(mom, [now]) : output;
914
945
  },
915
946
 
916
947
  _relativeTime : {
@@ -945,6 +976,7 @@
945
976
  return this._ordinal.replace('%d', number);
946
977
  },
947
978
  _ordinal : '%d',
979
+ _ordinalParse : /\d{1,2}/,
948
980
 
949
981
  preparse : function (string) {
950
982
  return string;
@@ -1086,6 +1118,8 @@
1086
1118
  case 'a':
1087
1119
  case 'A':
1088
1120
  return config._locale._meridiemParse;
1121
+ case 'x':
1122
+ return parseTokenOffsetMs;
1089
1123
  case 'X':
1090
1124
  return parseTokenTimestampMs;
1091
1125
  case 'Z':
@@ -1120,7 +1154,7 @@
1120
1154
  case 'E':
1121
1155
  return parseTokenOneOrTwoDigits;
1122
1156
  case 'Do':
1123
- return parseTokenOrdinal;
1157
+ return strict ? config._locale._ordinalParse : config._locale._ordinalParseLenient;
1124
1158
  default :
1125
1159
  a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i'));
1126
1160
  return a;
@@ -1157,7 +1191,7 @@
1157
1191
  break;
1158
1192
  case 'MMM' : // fall through to MMMM
1159
1193
  case 'MMMM' :
1160
- a = config._locale.monthsParse(input);
1194
+ a = config._locale.monthsParse(input, token, config._strict);
1161
1195
  // if we didn't find a month name, mark the date as invalid.
1162
1196
  if (a != null) {
1163
1197
  datePartArray[MONTH] = a;
@@ -1174,7 +1208,8 @@
1174
1208
  break;
1175
1209
  case 'Do' :
1176
1210
  if (input != null) {
1177
- datePartArray[DATE] = toInt(parseInt(input, 10));
1211
+ datePartArray[DATE] = toInt(parseInt(
1212
+ input.match(/\d{1,2}/)[0], 10));
1178
1213
  }
1179
1214
  break;
1180
1215
  // DAY OF YEAR
@@ -1199,11 +1234,13 @@
1199
1234
  case 'A' :
1200
1235
  config._isPm = config._locale.isPM(input);
1201
1236
  break;
1202
- // 24 HOUR
1203
- case 'H' : // fall through to hh
1204
- case 'HH' : // fall through to hh
1237
+ // HOUR
1205
1238
  case 'h' : // fall through to hh
1206
1239
  case 'hh' :
1240
+ config._pf.bigHour = true;
1241
+ /* falls through */
1242
+ case 'H' : // fall through to HH
1243
+ case 'HH' :
1207
1244
  datePartArray[HOUR] = toInt(input);
1208
1245
  break;
1209
1246
  // MINUTE
@@ -1223,6 +1260,10 @@
1223
1260
  case 'SSSS' :
1224
1261
  datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000);
1225
1262
  break;
1263
+ // UNIX OFFSET (MILLISECONDS)
1264
+ case 'x':
1265
+ config._d = new Date(toInt(input));
1266
+ break;
1226
1267
  // UNIX TIMESTAMP WITH MS
1227
1268
  case 'X':
1228
1269
  config._d = new Date(parseFloat(input) * 1000);
@@ -1359,12 +1400,25 @@
1359
1400
  config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
1360
1401
  }
1361
1402
 
1403
+ // Check for 24:00:00.000
1404
+ if (config._a[HOUR] === 24 &&
1405
+ config._a[MINUTE] === 0 &&
1406
+ config._a[SECOND] === 0 &&
1407
+ config._a[MILLISECOND] === 0) {
1408
+ config._nextDay = true;
1409
+ config._a[HOUR] = 0;
1410
+ }
1411
+
1362
1412
  config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
1363
1413
  // Apply timezone offset from input. The actual zone can be changed
1364
1414
  // with parseZone.
1365
1415
  if (config._tzm != null) {
1366
1416
  config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm);
1367
1417
  }
1418
+
1419
+ if (config._nextDay) {
1420
+ config._a[HOUR] = 24;
1421
+ }
1368
1422
  }
1369
1423
 
1370
1424
  function dateFromObject(config) {
@@ -1378,7 +1432,7 @@
1378
1432
  config._a = [
1379
1433
  normalizedInput.year,
1380
1434
  normalizedInput.month,
1381
- normalizedInput.day,
1435
+ normalizedInput.day || normalizedInput.date,
1382
1436
  normalizedInput.hour,
1383
1437
  normalizedInput.minute,
1384
1438
  normalizedInput.second,
@@ -1451,6 +1505,10 @@
1451
1505
  config._pf.unusedInput.push(string);
1452
1506
  }
1453
1507
 
1508
+ // clear _12h flag if hour is <= 12
1509
+ if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
1510
+ config._pf.bigHour = undefined;
1511
+ }
1454
1512
  // handle am pm
1455
1513
  if (config._isPm && config._a[HOUR] < 12) {
1456
1514
  config._a[HOUR] += 12;
@@ -1459,7 +1517,6 @@
1459
1517
  if (config._isPm === false && config._a[HOUR] === 12) {
1460
1518
  config._a[HOUR] = 0;
1461
1519
  }
1462
-
1463
1520
  dateFromConfig(config);
1464
1521
  checkOverflow(config);
1465
1522
  }
@@ -1719,7 +1776,8 @@
1719
1776
 
1720
1777
  function makeMoment(config) {
1721
1778
  var input = config._i,
1722
- format = config._f;
1779
+ format = config._f,
1780
+ res;
1723
1781
 
1724
1782
  config._locale = config._locale || moment.localeData(config._l);
1725
1783
 
@@ -1743,7 +1801,14 @@
1743
1801
  makeDateFromInput(config);
1744
1802
  }
1745
1803
 
1746
- return new Moment(config);
1804
+ res = new Moment(config);
1805
+ if (res._nextDay) {
1806
+ // Adding is smart enough around DST
1807
+ res.add(1, 'd');
1808
+ res._nextDay = undefined;
1809
+ }
1810
+
1811
+ return res;
1747
1812
  }
1748
1813
 
1749
1814
  moment = function (input, format, locale, strict) {
@@ -1775,7 +1840,7 @@
1775
1840
  'release. Please refer to ' +
1776
1841
  'https://github.com/moment/moment/issues/1407 for more info.',
1777
1842
  function (config) {
1778
- config._d = new Date(config._i);
1843
+ config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
1779
1844
  }
1780
1845
  );
1781
1846
 
@@ -2087,7 +2152,12 @@
2087
2152
  toISOString : function () {
2088
2153
  var m = moment(this).utc();
2089
2154
  if (0 < m.year() && m.year() <= 9999) {
2090
- return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
2155
+ if ('function' === typeof Date.prototype.toISOString) {
2156
+ // native implementation is ~50x faster, use it when we can
2157
+ return this.toDate().toISOString();
2158
+ } else {
2159
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
2160
+ }
2091
2161
  } else {
2092
2162
  return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
2093
2163
  }
@@ -2206,7 +2276,7 @@
2206
2276
  diff < 1 ? 'sameDay' :
2207
2277
  diff < 2 ? 'nextDay' :
2208
2278
  diff < 7 ? 'nextWeek' : 'sameElse';
2209
- return this.format(this.localeData().calendar(format, this));
2279
+ return this.format(this.localeData().calendar(format, this, moment(now)));
2210
2280
  },
2211
2281
 
2212
2282
  isLeapYear : function () {
@@ -2275,36 +2345,45 @@
2275
2345
 
2276
2346
  endOf: function (units) {
2277
2347
  units = normalizeUnits(units);
2348
+ if (units === undefined || units === 'millisecond') {
2349
+ return this;
2350
+ }
2278
2351
  return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
2279
2352
  },
2280
2353
 
2281
2354
  isAfter: function (input, units) {
2355
+ var inputMs;
2282
2356
  units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
2283
2357
  if (units === 'millisecond') {
2284
2358
  input = moment.isMoment(input) ? input : moment(input);
2285
2359
  return +this > +input;
2286
2360
  } else {
2287
- return +this.clone().startOf(units) > +moment(input).startOf(units);
2361
+ inputMs = moment.isMoment(input) ? +input : +moment(input);
2362
+ return inputMs < +this.clone().startOf(units);
2288
2363
  }
2289
2364
  },
2290
2365
 
2291
2366
  isBefore: function (input, units) {
2367
+ var inputMs;
2292
2368
  units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
2293
2369
  if (units === 'millisecond') {
2294
2370
  input = moment.isMoment(input) ? input : moment(input);
2295
2371
  return +this < +input;
2296
2372
  } else {
2297
- return +this.clone().startOf(units) < +moment(input).startOf(units);
2373
+ inputMs = moment.isMoment(input) ? +input : +moment(input);
2374
+ return +this.clone().endOf(units) < inputMs;
2298
2375
  }
2299
2376
  },
2300
2377
 
2301
2378
  isSame: function (input, units) {
2379
+ var inputMs;
2302
2380
  units = normalizeUnits(units || 'millisecond');
2303
2381
  if (units === 'millisecond') {
2304
2382
  input = moment.isMoment(input) ? input : moment(input);
2305
2383
  return +this === +input;
2306
2384
  } else {
2307
- return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
2385
+ inputMs = +moment(input);
2386
+ return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
2308
2387
  }
2309
2388
  },
2310
2389
 
@@ -2481,7 +2560,7 @@
2481
2560
  },
2482
2561
 
2483
2562
  lang : deprecate(
2484
- 'moment().lang() is deprecated. Use moment().localeData() instead.',
2563
+ 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
2485
2564
  function (key) {
2486
2565
  if (key === undefined) {
2487
2566
  return this.localeData();
@@ -2702,7 +2781,7 @@
2702
2781
  return units === 'month' ? months : months / 12;
2703
2782
  } else {
2704
2783
  // handle milliseconds separately because of floating point math errors (issue #1867)
2705
- days = this._days + yearsToDays(this._months / 12);
2784
+ days = this._days + Math.round(yearsToDays(this._months / 12));
2706
2785
  switch (units) {
2707
2786
  case 'week': return days / 7 + this._milliseconds / 6048e5;
2708
2787
  case 'day': return days + this._milliseconds / 864e5;
@@ -2804,6 +2883,7 @@
2804
2883
 
2805
2884
  // Set default locale, other locale will inherit from English.
2806
2885
  moment.locale('en', {
2886
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
2807
2887
  ordinal : function (number) {
2808
2888
  var b = number % 10,
2809
2889
  output = (toInt(number % 100 / 10) === 1) ? 'th' :