Skip to content

Commit

Permalink
fix: Fix Hungarian (hu) locale (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
vassbence authored Oct 21, 2020
1 parent 9a407a1 commit ab13754
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/locale/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ const locale = {
relativeTime: {
future: '%s múlva',
past: '%s',
s: 'néhány másodperc',
m: 'egy perc',
mm: '%d perc',
h: 'egy óra',
hh: '%d óra',
d: 'egy nap',
dd: '%d nap',
M: 'egy hónap',
MM: '%d hónap',
y: 'egy éve',
yy: '%d év'
s: (_, s, ___, isFuture) => `néhány másodperc${isFuture || s ? '' : 'e'}`,
m: (_, s, ___, isFuture) => `egy perc${isFuture || s ? '' : 'e'}`,
mm: (n, s, ___, isFuture) => `${n} perc${isFuture || s ? '' : 'e'}`,
h: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'óra' : 'órája'}`,
hh: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'óra' : 'órája'}`,
d: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'nap' : 'napja'}`,
dd: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'nap' : 'napja'}`,
M: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'hónap' : 'hónapja'}`,
MM: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'hónap' : 'hónapja'}`,
y: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'év' : 'éve'}`,
yy: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'év' : 'éve'}`
},
formats: {
LT: 'H:mm',
Expand All @@ -38,4 +38,3 @@ const locale = {
dayjs.locale(locale, null, true)

export default locale

45 changes: 45 additions & 0 deletions test/locale/hu.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import moment from 'moment'
import dayjs from '../../src'
import relativeTime from '../../src/plugin/relativeTime'
import '../../src/locale/hu'

dayjs.extend(relativeTime)

it('RelativeTime: Time from X', () => {
const T = [
[44.4, 'second'], // a few seconds
[89.5, 'second'], // a minute
[2, 'minute'], // 2 minutes
[43, 'minute'], // 43 minutes
[45, 'minute'], // an hour
[3, 'hour'], // 3 hours
[21, 'hour'], // 21 hours
[1, 'day'], // a day
[3, 'day'], // 3 day
[25, 'day'], // 25 days
[1, 'month'], // a month
[2, 'month'], // 2 month
[10, 'month'], // 10 month
[1, 'year'], // a year
[2, 'year'], // 2 year
[5, 'year'], // 5 year
[18, 'month'] // 2 years
]

T.forEach((t) => {
dayjs.locale('hu')
moment.locale('hu')

const dayjsDay = dayjs()
const momentDay = moment()

const dayjsCompare = dayjs().add(t[0], t[1])
const momentCompare = moment().add(t[0], t[1])

expect(dayjsDay.from(dayjsCompare)).toBe(momentDay.from(momentCompare))

expect(dayjsDay.to(dayjsCompare)).toBe(momentDay.to(momentCompare))

expect(dayjsDay.from(dayjsCompare, true)).toBe(momentDay.from(momentCompare, true))
})
})

0 comments on commit ab13754

Please sign in to comment.