From b872c2851aab2bd72cd00917e2ac89900731d257 Mon Sep 17 00:00:00 2001 From: CJ Skillingstad Date: Mon, 8 Mar 2021 11:35:11 -0800 Subject: [PATCH] Add ru meridiem and unit tests --- 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 9fa5a6b70..801c85929 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 9044eb59a..7f285f636 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('вечера') +})