Skip to content

Commit

Permalink
fix: Update Ukrainian (uk) locale relative time (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
allmoviestvshowslistsfilmography28 committed Mar 19, 2020
1 parent 0191327 commit 04733d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/locale/uk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
Expand All @@ -35,7 +37,7 @@ const locale = {
s: 'декілька секунд',
m: relativeTimeWithPlural,
mm: relativeTimeWithPlural,
h: 'годину',
h: relativeTimeWithPlural,
hh: relativeTimeWithPlural,
d: 'день',
dd: relativeTimeWithPlural,
Expand Down
11 changes: 10 additions & 1 deletion test/plugin/relativeTime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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))
})

0 comments on commit 04733d6

Please sign in to comment.