From f10f39de7db70244a3c35e4a421090a12972457b Mon Sep 17 00:00:00 2001 From: CJ Skillingstad Date: Mon, 8 Mar 2021 20:27:56 -0800 Subject: [PATCH] fix: update Russian [ru] locale meridiem and unit tests (#1403) --- src/locale/ru.js | 12 +++++++++++- test/locale/ru.test.js | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/locale/ru.js b/src/locale/ru.js index 9fa5a6b7..801c8592 100644 --- a/src/locale/ru.js +++ b/src/locale/ru.js @@ -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) diff --git a/test/locale/ru.test.js b/test/locale/ru.test.js index 9044eb59..7f285f63 100644 --- a/test/locale/ru.test.js +++ b/test/locale/ru.test.js @@ -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('вечера') +})