diff --git a/src/locale/ms.js b/src/locale/ms.js index 4c4fea9cc..b58df0788 100644 --- a/src/locale/ms.js +++ b/src/locale/ms.js @@ -10,12 +10,12 @@ const locale = { monthsShort: 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'), weekStart: 1, formats: { - LT: 'HH.mm', - LTS: 'HH.mm.ss', + LT: 'HH:mm', + LTS: 'HH:mm:ss', L: 'DD/MM/YYYY', LL: 'D MMMM YYYY', - LLL: 'D MMMM YYYY HH.mm', - LLLL: 'dddd, D MMMM YYYY HH.mm' + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd, D MMMM YYYY HH:mm' }, relativeTime: { future: 'dalam %s', diff --git a/test/locale/ms.test.js b/test/locale/ms.test.js new file mode 100644 index 000000000..b417a58c6 --- /dev/null +++ b/test/locale/ms.test.js @@ -0,0 +1,50 @@ +import moment from 'moment' +import dayjs from '../../src' +import '../../src/locale/ms' +import localizedFormat from '../../src/plugin/localizedFormat' + +dayjs.extend(localizedFormat) + +describe('Malay locale localized time formats', () => { + beforeEach(() => { + dayjs.locale('ms') + moment.locale('ms') + }) + + afterEach(() => { + dayjs.locale('en') + moment.locale('en') + }) + + it('uses colon separators for LT and LTS', () => { + const date = '2019-07-15T13:05:09' + const dayjsDate = dayjs(date) + + expect(dayjsDate.format('LT')).toBe('13:05') + expect(dayjsDate.format('LTS')).toBe('13:05:09') + expect(dayjsDate.format('LT')).not.toContain('.') + expect(dayjsDate.format('LTS')).not.toContain('.') + }) + + it('formats LT, LTS, L, LL, LLL, LLLL correctly', () => { + const date = '2019-07-15T13:05:09' + const dayjsDate = dayjs(date) + + expect(dayjsDate.format('LT')).toBe('13:05') + expect(dayjsDate.format('LTS')).toBe('13:05:09') + expect(dayjsDate.format('L')).toBe('15/07/2019') + expect(dayjsDate.format('LL')).toBe('15 Julai 2019') + expect(dayjsDate.format('LLL')).toBe('15 Julai 2019 13:05') + expect(dayjsDate.format('LLLL')).toBe('Isnin, 15 Julai 2019 13:05') + }) + + it('matches moment for non-time formats (L, LL)', () => { + const date = '2019-07-15T13:05:09' + const dayjsDate = dayjs(date) + const momentDate = moment(date); + ['L', 'LL'].forEach((token) => { + expect(dayjsDate.format(token)).toBe(momentDate.format(token)) + }) + }) +}) +