Skip to content

Commit

Permalink
fix: update Russian [ru] locale meridiem and unit tests (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjskillingstad committed Mar 9, 2021
1 parent 8d9a5ae commit f10f39d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/locale/ru.js
Expand Up @@ -77,7 +77,17 @@ const locale = {
y: 'год',
yy: relativeTimeWithPlural
},
ordinal: n => n
ordinal: n => n,
meridiem: (hour) => {
if (hour < 4) {
return 'ночи'
} else if (hour < 12) {
return 'утра'
} else if (hour < 17) {
return 'дня'
}
return 'вечера'
}
}

dayjs.locale(locale, null, true)
Expand Down
7 changes: 7 additions & 0 deletions test/locale/ru.test.js
Expand Up @@ -47,3 +47,10 @@ it('RelativeTime: Time from X', () => {
.toBe(moment().from(moment().add(t[0], t[1]), true))
})
})

it('Meridiem', () => {
expect(dayjs('2020-01-01 03:00:00').locale('ru').format('A')).toEqual('ночи')
expect(dayjs('2020-01-01 11:00:00').locale('ru').format('A')).toEqual('утра')
expect(dayjs('2020-01-01 16:00:00').locale('ru').format('A')).toEqual('дня')
expect(dayjs('2020-01-01 20:00:00').locale('ru').format('A')).toEqual('вечера')
})

0 comments on commit f10f39d

Please sign in to comment.