Repository URL to install this package:
|
Version:
3.12.2 ▾
|
import capitalizeFirstLetter from './capitalizeFirstLetter';
import humanReadableDate from './humanReadableDate';
/**
* Wrapper over function humanReadableDate but with translations
*/
var humanReadableDateWithTranslations = function humanReadableDateWithTranslations(date, i18n) {
var t = function t(str) {
return i18n("timeAgo".concat(str.split(' ').filter(Boolean).map(function (item) {
return capitalizeFirstLetter(item.trim());
}).join('')), str) || str;
};
return humanReadableDate(date, {
ago: t('ago'),
second: t('second'),
seconds: t('seconds'),
minute: t('minute'),
minutes: t('minutes'),
hour: t('hour'),
hours: t('hours'),
day: t('day'),
days: t('days'),
month: t('month'),
months: t('months'),
year: t('year'),
years: t('years')
});
};
export default humanReadableDateWithTranslations;