From: Takuya Sawada Date: Wed, 29 Apr 2020 21:48:05 +0000 (+0900) Subject: [locale] ja: Add new 'Reiwa' Era (#5471) X-Git-Tag: 2.25.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=709579ab504c93657826cfa1954e37ff2647d7df;p=thirdparty%2Fmoment.git [locale] ja: Add new 'Reiwa' Era (#5471) * [locale] ja: Add new 'Reiwa' Era * Apply coding convention --- diff --git a/src/locale/ja.js b/src/locale/ja.js index 612a36984..227591055 100644 --- a/src/locale/ja.js +++ b/src/locale/ja.js @@ -6,6 +6,13 @@ import moment from '../moment'; export default moment.defineLocale('ja', { eras: [ + { + since: '2019-05-01', + offset: 1, + name: '令和', + narrow: '㋿', + abbr: 'R', + }, { since: '1989-01-08', offset: 1, diff --git a/src/test/locale/ja.js b/src/test/locale/ja.js index b4481e303..d3041ae8f 100644 --- a/src/test/locale/ja.js +++ b/src/test/locale/ja.js @@ -81,42 +81,36 @@ test('format', function (assert) { test('parse era', function (assert) { // strict - assert.equal( - moment('平成30年', 'NNNNy年', true).isValid(), - true, - '平成30年' - ); - assert.equal(moment('平成30年', 'NNNNy年', true).year(), 2018, '平成30年'); - assert.equal( - moment('平成30年', 'NNNNyo', true).isValid(), - true, - '平成30年' - ); - assert.equal(moment('平成30年', 'NNNNyo', true).year(), 2018, '平成30年'); + assert.equal(moment('令和2年', 'NNNNy年', true).isValid(), true, '令和2年'); + assert.equal(moment('令和2年', 'NNNNy年', true).year(), 2020, '令和2年'); + assert.equal(moment('令和2年', 'NNNNyo', true).isValid(), true, '令和2年'); + assert.equal(moment('令和2年', 'NNNNyo', true).year(), 2020, '令和2年'); - assert.equal(moment('平成30年', 'Ny年', true).isValid(), false, '平成30年'); - assert.equal(moment('平成30年', 'Ny年', false).isValid(), true, '平成30年'); - assert.equal(moment('㍻30年', 'Ny年', true).isValid(), false, '㍻30年'); - assert.equal(moment('㍻30年', 'Ny年', false).isValid(), true, '㍻30年'); - assert.equal(moment('H30年', 'Ny年', false).isValid(), true, 'H30年'); + assert.equal(moment('令和2年', 'Ny年', true).isValid(), false, '令和2年'); + assert.equal(moment('令和2年', 'Ny年', false).isValid(), true, '令和2年'); + assert.equal(moment('㋿2年', 'Ny年', true).isValid(), false, '㋿2年'); + assert.equal(moment('㋿2年', 'Ny年', false).isValid(), true, '㋿2年'); + assert.equal(moment('R2', 'Ny', false).isValid(), true, 'R2'); // abbrv - assert.equal(moment('H30年', 'Ny年', true).isValid(), true, 'H30年'); - assert.equal(moment('H30年', 'Ny年', true).year(), 2018, 'H30年'); - assert.equal(moment('H30年', 'NNNNy年', true).isValid(), false, 'H30年'); - assert.equal(moment('H30年', 'NNNNNy年', true).isValid(), false, 'H30年'); + assert.equal(moment('R2', 'Ny', true).isValid(), true, 'R2'); + assert.equal(moment('R2', 'Ny', true).year(), 2020, 'R2'); + assert.equal(moment('R2', 'NNNNy', true).isValid(), false, 'R2'); + assert.equal(moment('R2', 'NNNNNy', true).isValid(), false, 'R2'); // narrow - assert.equal(moment('㍻30年', 'Ny年', true).isValid(), false, '㍻30年'); - assert.equal(moment('㍻30年', 'NNNNy年', true).isValid(), false, '㍻30年'); - assert.equal(moment('㍻30年', 'NNNNNy年', true).isValid(), true, '㍻30年'); - assert.equal(moment('㍻30年', 'NNNNNy年', true).year(), 2018, '㍻30年'); + assert.equal(moment('㋿2年', 'Ny年', true).isValid(), false, '㋿2年'); + assert.equal(moment('㋿2年', 'NNNNy年', true).isValid(), false, '㋿2年'); + assert.equal(moment('㋿2年', 'NNNNNy年', true).isValid(), true, '㋿2年'); + assert.equal(moment('㋿2年', 'NNNNNy年', true).year(), 2020, '㋿2年'); // ordinal year - assert.equal(moment('平成30年', 'NNNNyo', true).year(), 2018, '平成30年'); - assert.equal(moment('平成元年', 'NNNNyo', true).year(), 1989, '平成元年'); + assert.equal(moment('令和2年', 'NNNNyo', true).year(), 2020, '平成30年'); + assert.equal(moment('令和元年', 'NNNNyo', true).year(), 2019, '平成元年'); // old eras + assert.equal(moment('平成30年', 'NNNNyo', true).year(), 2018, '平成30年'); + assert.equal(moment('平成元年', 'NNNNyo', true).year(), 1989, '平成元年'); assert.equal(moment('昭和64年', 'NNNNyo', true).year(), 1989, '昭和64年'); assert.equal(moment('昭和元年', 'NNNNyo', true).year(), 1926, '昭和元年'); assert.equal(moment('大正元年', 'NNNNyo', true).year(), 1912, '大正元年'); @@ -125,6 +119,20 @@ test('parse era', function (assert) { test('format era', function (assert) { var a = [ + /* First day of Reiwa Era */ + ['+002019-05-01', 'N, NN, NNN', 'R, R, R'], + ['+002019-05-01', 'NNNN', '令和'], + ['+002019-05-01', 'NNNNN', '㋿'], + ['+002019-05-01', 'y yy yyy yyyy', '1 01 001 0001'], + ['+002019-05-01', 'yo', '元年'], + + /* Last day of Heisei Era */ + ['+002019-04-30', 'N, NN, NNN', 'H, H, H'], + ['+002019-04-30', 'NNNN', '平成'], + ['+002019-04-30', 'NNNNN', '㍻'], + ['+002019-04-30', 'y yy yyy yyyy', '31 31 031 0031'], + ['+002019-04-30', 'yo', '31年'], + /* First day of Heisei Era */ ['+001989-01-08', 'N, NN, NNN', 'H, H, H'], ['+001989-01-08', 'NNNN', '平成'],