mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 02:01:29 +10:00
- add multiple languages
- switch from moment to dayjs
This commit is contained in:
14
src/utils/dayjs.js
Normal file
14
src/utils/dayjs.js
Normal file
@ -0,0 +1,14 @@
|
||||
import dayjs from 'dayjs';
|
||||
import 'dayjs/locale/da';
|
||||
import 'dayjs/locale/de';
|
||||
import 'dayjs/locale/en';
|
||||
import 'dayjs/locale/es';
|
||||
import 'dayjs/locale/fi';
|
||||
import 'dayjs/locale/fr';
|
||||
import 'dayjs/locale/kn';
|
||||
import 'dayjs/locale/nl';
|
||||
import 'dayjs/locale/pt';
|
||||
import 'dayjs/locale/tr';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
@ -1,5 +1,5 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { get, isEmpty } from 'lodash';
|
||||
import moment from 'moment/min/moment-with-locales';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const getModalText = (isEditMode, type) => {
|
||||
@ -25,12 +25,12 @@ export const isFileImage = (file) => {
|
||||
export const formatDateRange = ({ startDate, endDate }) => {
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const start = `${moment(startDate)
|
||||
const start = `${dayjs(startDate)
|
||||
.locale(i18n.language.substr(0, 2))
|
||||
.format('MMMM Y')}`;
|
||||
.format('MMMM YYYY')}`;
|
||||
|
||||
const end = moment(endDate).isValid()
|
||||
? `${moment(endDate).locale(i18n.language.substr(0, 2)).format('MMMM Y')}`
|
||||
const end = dayjs(endDate).isValid()
|
||||
? `${dayjs(endDate).locale(i18n.language.substr(0, 2)).format('MMMM YYYY')}`
|
||||
: 'Present';
|
||||
|
||||
return `${start} - ${end}`;
|
||||
|
||||
Reference in New Issue
Block a user