From: Chanintorn Asavavichairoj Date: Tue, 31 May 2016 03:36:26 +0000 (+0700) Subject: Fixed short thai months with unit-test X-Git-Tag: 2.14.0~29^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd641f031b0ddbb3e7e8c166d92bb804e8ed733e;p=thirdparty%2Fmoment.git Fixed short thai months with unit-test --- diff --git a/src/locale/th.js b/src/locale/th.js index 107e0a94b..8e29b016e 100644 --- a/src/locale/th.js +++ b/src/locale/th.js @@ -6,7 +6,7 @@ import moment from '../moment'; export default moment.defineLocale('th', { months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'), - monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'), + monthsShort : 'ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.'.split('_'), monthsParseExact: true, weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'), weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference @@ -55,4 +55,3 @@ export default moment.defineLocale('th', { yy : '%d ปี' } }); - diff --git a/src/test/locale/th.js b/src/test/locale/th.js index 885f8c0e3..9335ef9b4 100644 --- a/src/test/locale/th.js +++ b/src/test/locale/th.js @@ -3,7 +3,7 @@ import moment from '../../moment'; localeModule('th'); test('parse', function (assert) { - var tests = 'มกราคม มกรา_กุมภาพันธ์ กุมภา_มีนาคม มีนา_เมษายน เมษา_พฤษภาคม พฤษภา_มิถุนายน มิถุนา_กรกฎาคม กรกฎา_สิงหาคม สิงหา_กันยายน กันยา_ตุลาคม ตุลา_พฤศจิกายน พฤศจิกา_ธันวาคม ธันวา'.split('_'), i; + var tests = 'มกราคม ม.ค._กุมภาพันธ์ ก.พ._มีนาคม มี.ค._เมษายน เม.ย._พฤษภาคม พ.ค._มิถุนายน มิ.ย._กรกฎาคม ก.ค._สิงหาคม ส.ค._กันยายน ก.ย._ตุลาคม ต.ค._พฤศจิกายน พ.ย._ธันวาคม ธ.ค.'.split('_'), i; function equalTest(input, mmm, i) { assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1)); } @@ -24,7 +24,7 @@ test('format', function (assert) { var a = [ ['dddd, Do MMMM YYYY, h:mm:ss a', 'อาทิตย์, 14 กุมภาพันธ์ 2010, 3:25:50 หลังเที่ยง'], ['ddd, h A', 'อาทิตย์, 3 หลังเที่ยง'], - ['M Mo MM MMMM MMM', '2 2 02 กุมภาพันธ์ กุมภา'], + ['M Mo MM MMMM MMM', '2 2 02 กุมภาพันธ์ ก.พ.'], ['YYYY YY', '2010 10'], ['D Do DD', '14 14 14'], ['d do dddd ddd dd', '0 0 อาทิตย์ อาทิตย์ อา.'], @@ -42,9 +42,9 @@ test('format', function (assert) { ['LLL', '14 กุมภาพันธ์ 2010 เวลา 15 นาฬิกา 25 นาที'], ['LLLL', 'วันอาทิตย์ที่ 14 กุมภาพันธ์ 2010 เวลา 15 นาฬิกา 25 นาที'], ['l', '2010/2/14'], - ['ll', '14 กุมภา 2010'], - ['lll', '14 กุมภา 2010 เวลา 15 นาฬิกา 25 นาที'], - ['llll', 'วันอาทิตย์ที่ 14 กุมภา 2010 เวลา 15 นาฬิกา 25 นาที'] + ['ll', '14 ก.พ. 2010'], + ['lll', '14 ก.พ. 2010 เวลา 15 นาฬิกา 25 นาที'], + ['llll', 'วันอาทิตย์ที่ 14 ก.พ. 2010 เวลา 15 นาฬิกา 25 นาที'] ], b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), i; @@ -54,7 +54,7 @@ test('format', function (assert) { }); test('format month', function (assert) { - var expected = 'มกราคม มกรา_กุมภาพันธ์ กุมภา_มีนาคม มีนา_เมษายน เมษา_พฤษภาคม พฤษภา_มิถุนายน มิถุนา_กรกฎาคม กรกฎา_สิงหาคม สิงหา_กันยายน กันยา_ตุลาคม ตุลา_พฤศจิกายน พฤศจิกา_ธันวาคม ธันวา'.split('_'), i; + var expected = 'มกราคม ม.ค._กุมภาพันธ์ ก.พ._มีนาคม มี.ค._เมษายน เม.ย._พฤษภาคม พ.ค._มิถุนายน มิ.ย._กรกฎาคม ก.ค._สิงหาคม ส.ค._กันยายน ก.ย._ตุลาคม ต.ค._พฤศจิกายน พ.ย._ธันวาคม ธ.ค.'.split('_'), i; for (i = 0; i < expected.length; i++) { assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]); } @@ -169,4 +169,3 @@ test('weeks year starting sunday format', function (assert) { assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2'); assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3'); }); -