Skip to content

Commit

Permalink
fix: Update Swedish locale (sv) fix ordinal error (#745)
Browse files Browse the repository at this point in the history
fix #743
  • Loading branch information
iamkun committed Dec 8, 2019
1 parent 15d1b81 commit 49670d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/locale/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const locale = {
ordinal: (n) => {
const b = n % 10
const o = (b === 1) || (b === 2) ? 'a' : 'e'
return `${n}${o}`
return `[${n}${o}]`
},
formats: {
LT: 'HH:mm',
Expand Down
21 changes: 21 additions & 0 deletions test/locale/sv.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import MockDate from 'mockdate'
import dayjs from '../../src'
import advancedFormat from '../../src/plugin/advancedFormat'
import '../../src/locale/sv'

dayjs.extend(advancedFormat)

beforeEach(() => {
MockDate.set(new Date())
})

afterEach(() => {
MockDate.reset()
})

it('Swedish locale Do 1a not format to 1am', () => {
expect(dayjs('2019-01-01').locale('sv').format('dddd Do MMMM'))
.toBe('tisdag 1a januari')
expect(dayjs('2019-01-02').locale('sv').format('dddd Do MMMM'))
.toBe('onsdag 2a januari')
})

0 comments on commit 49670d5

Please sign in to comment.