From 1839ef85eca19d6deef9b480fe1c2944f1414249 Mon Sep 17 00:00:00 2001 From: Aleksey Lozovagin Date: Wed, 18 Mar 2020 16:02:51 +0200 Subject: [PATCH 1/3] fix: Update Ukrainian (uk) locale relative time --- src/locale/uk.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/locale/uk.js b/src/locale/uk.js index 4cfa84d8b..5457fb523 100644 --- a/src/locale/uk.js +++ b/src/locale/uk.js @@ -16,6 +16,8 @@ function relativeTimeWithPlural(number, withoutSuffix, key) { } if (key === 'm') { return withoutSuffix ? 'хвилина' : 'хвилину' + } else if(key === 'h') { + return withoutSuffix ? 'година' : 'годину' } return `${number} ${plural(format[key], +number)}` @@ -35,7 +37,7 @@ const locale = { s: 'декілька секунд', m: relativeTimeWithPlural, mm: relativeTimeWithPlural, - h: 'годину', + h: relativeTimeWithPlural, hh: relativeTimeWithPlural, d: 'день', dd: relativeTimeWithPlural, From 1a480f920c64c53830c44bd1445a9be907b4edea Mon Sep 17 00:00:00 2001 From: Aleksey Lozovagin Date: Wed, 18 Mar 2020 16:10:25 +0200 Subject: [PATCH 2/3] fix lint --- src/locale/uk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/uk.js b/src/locale/uk.js index 5457fb523..27bfacf1f 100644 --- a/src/locale/uk.js +++ b/src/locale/uk.js @@ -16,7 +16,7 @@ function relativeTimeWithPlural(number, withoutSuffix, key) { } if (key === 'm') { return withoutSuffix ? 'хвилина' : 'хвилину' - } else if(key === 'h') { + } else if (key === 'h') { return withoutSuffix ? 'година' : 'годину' } From 97fd4264564b204bb1f6d6b9bfed65ea3ba64981 Mon Sep 17 00:00:00 2001 From: Aleksey Lozovagin Date: Wed, 18 Mar 2020 19:28:01 +0200 Subject: [PATCH 3/3] add test func --- test/plugin/relativeTime.test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/plugin/relativeTime.test.js b/test/plugin/relativeTime.test.js index 11b1d5d55..84e3c439d 100644 --- a/test/plugin/relativeTime.test.js +++ b/test/plugin/relativeTime.test.js @@ -4,6 +4,7 @@ import dayjs from '../../src' import relativeTime from '../../src/plugin/relativeTime' import utc from '../../src/plugin/utc' import '../../src/locale/ru' +import '../../src/locale/uk' dayjs.extend(relativeTime) @@ -84,7 +85,7 @@ it('Time to X', () => { expect(dayjs().to(dayjs().subtract(3, 'year'))).toBe(moment().to(moment().subtract(3, 'year'))) }) -it('Locale Fonction', () => { +it('Locale Function', () => { // e.g. in ru locale, m: x minute require additional processing // and provides as a function instead of a string const str0 = '2020-01-06 15:53:00' @@ -115,3 +116,11 @@ it('Time from now with UTC', () => { expect(dutc.fromNow()).toBe(mutc.fromNow()) }) + +it('Uk locale hour', () => { + const str0 = '2020-03-18 19:15:00' + const str = '2020-03-18 20:15:00' + const result = dayjs(str0).locale('uk').to(str) + + expect(result).toEqual(moment(str0).locale('uk').to(str)) +})