Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/locale/ms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
50 changes: 50 additions & 0 deletions test/locale/ms.test.js
Original file line number Diff line number Diff line change
@@ -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))
})
})
})

Loading