]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Apply PR comments
authorIskren Chernev <iskren.chernev@gmail.com>
Sat, 9 Jan 2016 09:31:26 +0000 (11:31 +0200)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 9 Jan 2016 09:36:35 +0000 (11:36 +0200)
src/lib/units/year.js
src/test/moment/format.js

index 5244e0c0ea0ac09fa28c1cf40adf1dd74e5f24c8..a09e5e3acbfc96096665a71ce612ca49382239a6 100644 (file)
@@ -11,14 +11,7 @@ import toInt from '../utils/to-int';
 
 addFormatToken('Y', 0, 0, function () {
     var y = this.year();
-    if (y < 0) {
-        return y;
-    } else if (y <= 9999) {
-        return y;
-    } else {
-        // force plus for longer years.
-        return '+' + y;
-    }
+    return y <= 9999 ? '' + y : '+' + y;
 });
 
 addFormatToken(0, ['YY', 2], 0, function () {
index f20cab2a0253f70be0fb3d0cd9108f425df27345..2e600666213e6e918b997ce8a399a5e0a2af2195 100644 (file)
@@ -429,4 +429,8 @@ test('Y token', function (assert) {
     assert.equal(moment('2010-01-01', 'YYYY-MM-DD', true).format('Y'), '2010', 'format 2010 with Y');
     assert.equal(moment('-123-01-01', 'Y-MM-DD', true).format('Y'), '-123', 'format -123 with Y');
     assert.equal(moment('12345-01-01', 'Y-MM-DD', true).format('Y'), '+12345', 'format 12345 with Y');
+    assert.equal(moment('0-01-01', 'Y-MM-DD', true).format('Y'), '0', 'format 0 with Y');
+    assert.equal(moment('1-01-01', 'Y-MM-DD', true).format('Y'), '1', 'format 1 with Y');
+    assert.equal(moment('9999-01-01', 'Y-MM-DD', true).format('Y'), '9999', 'format 9999 with Y');
+    assert.equal(moment('10000-01-01', 'Y-MM-DD', true).format('Y'), '+10000', 'format 10000 with Y');
 });