nuxt-community / date-fns-module

Modern JavaScript date utility library - date-fns for Nuxt.js
MIT License
78 stars 8 forks source link

formatDuration not being localized #37

Closed codesxt closed 4 years ago

codesxt commented 4 years ago

I'm working with several dates in Spanish with the 'es' locale. Most of them are working fine, like 'formatDistanceToNow' which gives me the date distance in proper Spanish. But when I call 'formatDuration' it gives me the result in English.

When I force the locale using $dateFns.formatDuration(duration, { locale: 'es' }) it gives me the following rendering error:

locale.formatDistance is not a function`

I'm using:

Locale objects are being properly loaded from date-fns so the problem must be in this plugin.

codesxt commented 4 years ago

I just realized that the error is solved by adding 'formatDuration' to the twoParams array in the file @nuxtjs/date-fns/lib/plugin.js.

I'll add a PR to add that.

ricardogobbosouza commented 4 years ago

Thanks @codesxt

codesxt commented 4 years ago

@ricardogobbosouza Will this be in a new version soon? Just to know.

ricardogobbosouza commented 4 years ago

@codesxt release v1.4.0